-
gen_codes.sh
を配置する。#!/bin/bash # スクリプトのファイル名を取得し、拡張子を変更して出力ファイル名を設定 script_name=$(basename "$0") output_file="${script_name%.sh}.txt" # 除外するディレクトリ名とファイル名を配列で指定 exclude_dirs=("__pycache__" "venv" ".dart_tool" "build") exclude_files=("$script_name" "$output_file" ".gitignore" "__init__.py") # 出力ファイルを初期化 > "$output_file" # 除外パターンを作成 exclude_args=() for dir in "${exclude_dirs[@]}"; do exclude_args+=( -path "*/$dir/*" -prune -o ) done for file in "${exclude_files[@]}"; do exclude_args+=( -name "$file" -o ) done # ディレクトリ構造をtree形式で出力 echo "Directory Structure" >> "$output_file" echo "===================" >> "$output_file" find . \( "${exclude_args[@]}" -false \) -o -print | sed -e 's|[^/]*/| |g' -e 's| |├── |g' -e 's|── |── |g' >> "$output_file" echo "" >> "$output_file" # 出力ファイルのヘッダーにファイル内容の概要を追加 echo "File Contents" >> "$output_file" echo "=============" >> "$output_file" echo "" >> "$output_file" # findコマンドを組み立てて実行 find . \( "${exclude_args[@]}" -type f -print \) | while read -r file; do # ファイルパスの先頭 "./" を "/" に置き換え relative_path="${file#./}" echo "=== /$relative_path ===" >> "$output_file" cat "$file" >> "$output_file" echo -e "\n\n" >> "$output_file" done echo "Directory structure and contents have been written to $output_file"
-
./gen_codes.sh
を実行すると、gen_codes.txt
が出力される。 -
LLMに投入して会話を続ける。
LLMからアドバイスを貰うためにディレクトリ構成とファイル内容を1つのテキストファイルに書き出すスクリプト
Last updated at Posted at 2024-08-03
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme