1
0
Fork 0

feat (tmux): Adding session management by convention

pull/949/head
Michael Yockey 9 years ago
parent e792d78b71
commit 5d5499ef90

@ -44,6 +44,8 @@ Aliases
- `tmuxa` attaches or switches to a tmux session. - `tmuxa` attaches or switches to a tmux session.
- `tmuxl` lists sessions managed by the tmux server. - `tmuxl` lists sessions managed by the tmux server.
- `tmuxn` creates or attaches to a session named for the passed argument or,
if non is provided, the current working directory.
Caveats Caveats
------- -------

@ -0,0 +1,3 @@
#compdef tmux-new-session
compadd $(tmux list-sessions -F \#S | sed "s/[\* ]//g")

@ -0,0 +1,9 @@
#
# Defines the naming convention for tmux-new-session
#
# Author:
# Michael Yockey <myockey@gmail.com>
#
TMUX_CONVENTIONAL_SESSION_NAME=$(basename $(pwd))

@ -0,0 +1,24 @@
#
# Creates or reattaches to a tmux session based on a naming convention
#
# Author:
# Michael Yockey <myockey@gmail.com>
#
local name
if [[ -n $1 ]]; then
name=$1
else
name=$TMUX_CONVENTIONAL_SESSION_NAME
fi
tmux list-sessions | grep -q "^$name:"
if [ $? = 0 ]; then
tmux attach-session -t $name
else
tmux new-session -s $name
fi
return 0

@ -41,19 +41,9 @@ if [[ -z "$TMUX" && -z "$EMACS" && -z "$VIM" ]] && ( \
exec tmux $_tmux_iterm_integration attach-session exec tmux $_tmux_iterm_integration attach-session
fi fi
# # Initialize the session naming convention and update it before every command
# Functions set-conventional-session-name
# preexec_functions=(${preexec_functions[@]} "set-conventional-session-name")
tmux-new-session() {
local name=$(basename $(pwd))
tmux list-sessions | grep -q "^$name:"
if [ $? = 0 ]; then
tmux attach-session -t $name
else
tmux new-session -s $name
fi
}
# #
# Aliases # Aliases

Loading…
Cancel
Save