Created
March 26, 2015 14:44
-
-
Save jaronson/42db12240a4b783dea3d to your computer and use it in GitHub Desktop.
tmuxg
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