Skip to content

Instantly share code, notes, and snippets.

@nerdyslacker
Created August 14, 2025 18:31
Show Gist options
  • Save nerdyslacker/7fb728e89a2e097a9bdbb1c626f402ca to your computer and use it in GitHub Desktop.
Save nerdyslacker/7fb728e89a2e097a9bdbb1c626f402ca to your computer and use it in GitHub Desktop.
Rofi-Based Project Launcher with IDE Selection
#!/usr/bin/env bash
# KEYBOARD SHORTCUTS
# Alt+S → show subprojects
# Alt+I → choose IDE
PROJECTS_DIR="$HOME/Projects"
DEFAULT_IDE="code"
declare -A IDES=(
["VS Code"]="code"
["Rider"]="rider"
["Zed"]="zed"
)
choose_project() {
local base_dir="$1"
declare -a stack=()
while true; do
menu_items=""
if [ ${#stack[@]} -gt 0 ]; then
menu_items=".. (Go Back)\n"
fi
menu_items+=$(find "$base_dir" -mindepth 1 -maxdepth 1 -type d -printf "%f\n" | sort)
selection=$(echo -e "$menu_items" | rofi -dmenu \
-p "Projects in $(basename "$base_dir")" \
-kb-custom-1 "Alt+s" \
-kb-custom-2 "Alt+i")
exit_code=$?
[ $exit_code -eq 1 ] && return 1
[ -z "$selection" ] && return 1
if [ "$selection" == ".. (Go Back)" ]; then
base_dir="${stack[-1]}"
unset 'stack[-1]'
continue
fi
selected_path="$base_dir/$selection"
if [ $exit_code -eq 10 ]; then
if [ "$(find "$selected_path" -mindepth 1 -maxdepth 1 -type d | wc -l)" -gt 0 ]; then
stack+=("$base_dir")
base_dir="$selected_path"
continue
else
notify-send "No subfolders in $selection"
fi
elif [ $exit_code -eq 11 ]; then
choose_ide "$selected_path"
break
else
"$DEFAULT_IDE" "$selected_path" &
break
fi
done
}
choose_ide() {
local project="$1"
local ide_list
ide_list=$(printf "%s\n" "${!IDES[@]}")
chosen_ide=$(echo "$ide_list" | rofi -dmenu -p "Choose IDE:")
[ -z "$chosen_ide" ] && return
eval "${IDES[$chosen_ide]} \"$project\"" &
}
choose_project "$PROJECTS_DIR"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment