Skip to content

Instantly share code, notes, and snippets.

@nickel-dev
Created July 12, 2025 20:55
Show Gist options
  • Save nickel-dev/d149174886c263d9620f851b1e081061 to your computer and use it in GitHub Desktop.
Save nickel-dev/d149174886c263d9620f851b1e081061 to your computer and use it in GitHub Desktop.
dmenu fuzzy finder written in shell script
#!/bin/sh
arg="${1:-.}"
arg=$(realpath -- "$arg") # Convert to absolute path
arg="${arg%/}" # Remove trailing slash
parent_dir=$(dirname -- "$arg")
file=$({ printf '.\n..\n'; find "$arg" -type f -printf '%P\n'; } | dmenu -p "File ($arg):" || exit 0)
# Handle selections
case "$file" in
".")
echo "$arg" # Current directory (absolute path)
exit 0
;;
"..")
exec "$0" "$parent_dir" # Restart script with parent directory
;;
*)
echo "$arg/$file" # Absolute path + selected file
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment