Created
July 12, 2025 20:55
-
-
Save nickel-dev/d149174886c263d9620f851b1e081061 to your computer and use it in GitHub Desktop.
dmenu fuzzy finder written in shell script
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 characters
#!/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