Last active
May 16, 2018 09:31
-
-
Save petja/3c4f7206ecf92641881381deb426c56e to your computer and use it in GitHub Desktop.
List own projects, change directory and attach tmux easily
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 | |
if [[ "$TERM" =~ "screen".* ]]; then | |
echo "You have to detach tmux before continuing" | |
else | |
if [ -z "$1" ]; then | |
printf "\n\e[3mWhich project you want to open?\e[0m\n\n" | |
ls -t ~/projects | |
printf "\n> " | |
read projectname | |
else | |
projectname=$1 | |
fi | |
if [ ! -d "$HOME/projects/$projectname" ]; then | |
printf "\e[0;31mCould not locate project folder for $projectname. You have to create it first.\e[0m\n" | |
else | |
cd ~/projects/$projectname | |
tmux new-session -As $projectname | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment