Created
June 11, 2025 14:41
-
-
Save jason-green-io/01b05b104b2caa4407f9d63fc2ddf350 to your computer and use it in GitHub Desktop.
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/bash | |
| SCRIPTS_DIR=~/scripts # Root directory for your scripts | |
| navigate() { | |
| local current_dir="$1" | |
| while true; do | |
| local items=() | |
| while IFS= read -r path; do | |
| if [ -d "$path" ]; then | |
| items+=("$(basename "$path")/") | |
| elif [[ "$path" == *.sh ]]; then | |
| items+=("$(basename "$path")") | |
| fi | |
| done < <(find "$current_dir" -maxdepth 1 -mindepth 1 | sort) | |
| items+=("..") | |
| local selection | |
| selection=$(printf "%s\n" "${items[@]}" | fzf --prompt="Browse: ${current_dir} > " --bind 'one:accept' --exit-0) | |
| [[ -z "$selection" ]] && exit # User pressed Esc or Ctrl-C | |
| [[ "$selection" == ".." ]] && return | |
| local full_path="$current_dir/${selection%/}" | |
| if [[ -d "$full_path" ]]; then | |
| echo "Navigating: $full_path" | |
| navigate "$full_path" | |
| elif [[ "$full_path" == *.sh ]]; then | |
| echo "Running: $full_path" | |
| "$full_path" | |
| exit 0 | |
| fi | |
| done | |
| } | |
| navigate "$SCRIPTS_DIR" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment