Skip to content

Instantly share code, notes, and snippets.

@Blumed
Last active April 6, 2024 19:04
Show Gist options
  • Save Blumed/37998462f734e39e0a620158c7a748c5 to your computer and use it in GitHub Desktop.
Save Blumed/37998462f734e39e0a620158c7a748c5 to your computer and use it in GitHub Desktop.
Simple bash function for opening any repo in your git project directory using any editor.
openWork() {
StartColor="\e[1;32m"
EndColor="\e[0m"
editor="code" # add command which opens files/dirs using your editor
workDirectory=(~/dev/) # add your path to your work directory
directories=($workDirectory*)
PS3="Enter the number associated with a directory you want to open with $editor? "
echo "There are ${StartColor}${#directories[@]}${EndColor} directories in ${StartColor}${workDirectory}${EndColor}:"; \
select directory in "${directories[@]##*/}"; do echo "Opening ${StartColor}${directory}${EndColor}"' with '${StartColor}${editor}${EndColor}'!'; $editor $workDirectory${directory}; break; done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment