Skip to content

Instantly share code, notes, and snippets.

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