Created
January 21, 2022 00:56
-
-
Save themaxhero/7f02dced6a940339b58432238d6bcadb to your computer and use it in GitHub Desktop.
Wofi Project Selector
This file contains 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 | |
__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