If cmd isn't specified in either the zstyle or $2, default to $SHELL. If dir is set, change the directory prior to starting tmux to change the working directory.

This commit is contained in:
Simon Gomizelj 2011-12-04 12:10:32 -05:00
commit 31b73808b4

View file

@ -34,16 +34,17 @@ if (( $+commands[tmux] )); then
t() { t() {
# Load the command or directory-path from config. # Load the command or directory-path from config.
zstyle -a :omz:plugins:tmux:cmd $1 cmd zstyle -a :omz:plugins:tmux:cmd $1 cmd; cmd=${cmd:-$2}
zstyle -a :omz:plugins:tmux:dir $1 dir zstyle -a :omz:plugins:tmux:dir $1 dir
(( $+commands[$cmd] )) || [[ -d $dir ]] || return 127 [[ -n $cmd ]] && (( ! $+commands[$cmd] )) && return 127
# start the command # start the command
# if ! tmux has -t $1 2>/dev/null; then # if ! tmux has -t $1 2>/dev/null; then
if ! tmux has -t $1; then if ! tmux has -t $1; then
# It would be nice to hide the message about set changing the default-path. (
[[ -d $dir ]] && (cd $dir && tmux new -s $1 \; set default-path ${dir}) [[ -d $dir ]] && cd $dir
(( $+commands[$cmd] )) && TMUX= tmux new -ds $1 ${cmd-$2} TMUX= tmux new -ds $1 ${cmd:-$SHELL}
)
fi fi
# switch or attach depending on if we're inside tmux # switch or attach depending on if we're inside tmux