Skip to content

Instantly share code, notes, and snippets.

@yeiichi
Last active January 13, 2025 10:55
Show Gist options
  • Save yeiichi/8aa4306865e9d24dde7aafdc98d33cd5 to your computer and use it in GitHub Desktop.
Save yeiichi/8aa4306865e9d24dde7aafdc98d33cd5 to your computer and use it in GitHub Desktop.
Display a numbered file list of a specified directory.
#!/usr/bin/env zsh
my_name=$(basename "$0")
display_help() {
cat <<EOF
${my_name}:
Display a numbered file list of a specified directory.
EOF
}
main() {
# display_help
printf 'DIR? >> '
read -r target_dir
count=1
for i in "${target_dir}"/*; do
printf '%3d: %s...\n' "${count}" "${i:0:64}"
count="$((count + 1))"
done
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment