-
-
Save schoblaska/4f923da5e395d1815e2819e200724910 to your computer and use it in GitHub Desktop.
Bash script to either create or attach to a named tmux session with the given working directory.
This file contains hidden or 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 [ "$1" != "" ]; then | |
cd $1 | |
fi | |
DIR_NAME=${PWD##*/} | |
tmux has-session -t $DIR_NAME 2>/dev/null | |
if [ $? -eq 1 ] | |
then | |
tmux new -s $DIR_NAME | |
else | |
tmux attach -t $DIR_NAME | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Eg:
tm ~/projects/myapp
will create a new tmux session in that directory with the namemyapp
, or attach to one if it already exists.tm
with no arguments will do the same but for the current directory.