Last active
October 4, 2025 00:20
-
-
Save yokawasa/abf581a5fcbe6fe97d197dd1a0bf57f6 to your computer and use it in GitHub Desktop.
Revisions
-
yokawasa revised this gist
Oct 4, 2025 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,9 @@ #!/bin/sh # 指定ディレクトリまたは現在のディレクトリを使用 [ -d "$1" ] && DIR=$1 && shift || DIR=. # ディレクトリを絶対パスに変換 (cd ${DIR}; pwd) # ディレクトリ内のファイルとサブディレクトリをツリー表示 find "${DIR}" | \ awk -v dir="${DIR}" ' function is_dir(path, cmd, result) { @@ -13,11 +13,11 @@ function is_dir(path, cmd, result) { return result == 1 } { sub("^" dir, "", $0) # 先頭ディレクトリパス削除 if ($0 == "") next # 空行スキップ n = split($0, parts, "/") # パスをスラッシュで分割 indent = "" for (i = 2; i < n; i++) indent = indent " " name = parts[n] if (is_dir($0)) { # ディレクトリは青色 -
yokawasa created this gist
Jul 19, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ #!/bin/sh # ディレクトリが指定されていればそれを使用、なければ現在のディレクトリを使用 [ -d "$1" ] && DIR=$1 && shift || DIR=. # ディレクトリを絶対パスに変換 (cd ${DIR}; pwd) # ディレクトリ内のファイルとサブディレクトリをリストアップし、ツリー形式で表示 find "${DIR}" | \ awk -v dir="${DIR}" ' function is_dir(path, cmd, result) { cmd = "test -d \"" dir path "\" && echo 1 || echo 0" cmd | getline result close(cmd) return result == 1 } { sub("^" dir, "", $0) # 先頭のディレクトリパスを削除 if ($0 == "") next # 空行はスキップ n = split($0, parts, "/") # パスをスラッシュで分割 indent = "" for (i = 2; i < n; i++) indent = indent " " # インデント作成 name = parts[n] if (is_dir($0)) { # ディレクトリは青色 print indent "+---\033[34m " name "\033[0m" } else { # ファイルは色なし print indent "+-- " name } } '