Skip to content

Instantly share code, notes, and snippets.

@petja
Last active May 16, 2018 09:31
Show Gist options
  • Save petja/3c4f7206ecf92641881381deb426c56e to your computer and use it in GitHub Desktop.
Save petja/3c4f7206ecf92641881381deb426c56e to your computer and use it in GitHub Desktop.
List own projects, change directory and attach tmux easily
#!/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