Skip to content

Instantly share code, notes, and snippets.

@themaxhero
Created January 21, 2022 00:56
Show Gist options
  • Save themaxhero/7f02dced6a940339b58432238d6bcadb to your computer and use it in GitHub Desktop.
Save themaxhero/7f02dced6a940339b58432238d6bcadb to your computer and use it in GitHub Desktop.
Wofi Project Selector
#!/bin/bash
__choice=$(printf '%s\n' Work Personal | wofi -dmenu -p "Select project scope" -L 2)
__work_projects=~/projects/work
__personal_projects=~/projects/personal
show_options() {
case $1 in
'Open with Emacs') emacs $2;;
'Open with Thunar') thunar $2;;
'Open with Alacritty') alacritty --working-directory $2;;
'Open with Codium') codium $2;;
*) echo "Invalid Option (This should be unreachable, though)";;
esac
}
ask_for_action(){
__action=$(printf '%s\n' 'Open with Emacs' 'Open with Thunar' 'Open with Alacritty' 'Open with Codium' | wofi -dmenu -p "What do you want to do with $1")
echo $__action
}
select_project_in_folder(){
ls -l "$1" | grep '^d' | awk '{print $9}'| wofi -dmenu -p "Select project" | echo
}
case $__choice in
"Work")
__company=$(ls "$__work_projects" | cat | wofi -dmenu -p "Select company")
__project=$(select_project_in_folder "$__work_projects/$__company")
__action=$(ask_for_action "$__project")
__project_folder="$__work_projects/$__company/$__project"
show_options "$__action" "$__project_folder" ;;
"Personal")
__project=$(select_project_in_folder "$__personal_projects")
__action=$(ask_for_action "$__project")
__project_folder="$__personal_projects/$__project"
show_options "$__action" "$__project_folder" ;;
*) echo "invalid option" ;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment