Created
August 4, 2015 02:23
-
-
Save jaronson/2c8e63309376c4812add to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
name=$1 | |
config='.tmuxrc' | |
[[ -n $name ]] && config=".$name.$config" | |
if [ ! -f "$config" ]; | |
then | |
echo "$0: cannot stat '${config}': No such file." | |
exit 1 | |
fi | |
sockname=$(basename "$(pwd)" | sed 's/[^a-zA-Z0-9\-]//g') | |
if ! tmux has-session -t "$sockname" > /dev/null 2>&1; | |
then | |
TMUX='' tmux new-session -d -s "$sockname" | |
xargs -L1 tmux < "$config" | |
tmux select-window -t 1 | |
fi | |
if [ -z "$TMUX" ]; | |
then | |
tmux attach -t "$sockname" | |
else | |
tmux switch-client -t "$sockname" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment