mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-19 21:41:07 +01:00
Make tmux plugin refresh tmux global environments automatically.
This commit is contained in:
parent
a29950146b
commit
fdf55dd5cc
1 changed files with 17 additions and 0 deletions
|
@ -22,6 +22,8 @@ alias tkss='tmux kill-session -t'
|
|||
: ${ZSH_TMUX_AUTOCONNECT:=true}
|
||||
# Automatically close the terminal when tmux exits
|
||||
: ${ZSH_TMUX_AUTOQUIT:=$ZSH_TMUX_AUTOSTART}
|
||||
# Automatically pick up tmux environments
|
||||
: ${ZSH_TMUX_AUTOREFRESH:=true}
|
||||
# Set term to screen or screen-256color based on current terminal support
|
||||
: ${ZSH_TMUX_FIXTERM:=true}
|
||||
# Set '-CC' option for iTerm2 tmux integration
|
||||
|
@ -74,6 +76,15 @@ function _zsh_tmux_plugin_run() {
|
|||
fi
|
||||
}
|
||||
|
||||
# Refresh tmux environment variables.
|
||||
function _zsh_tmux_plugin_preexec()
|
||||
{
|
||||
local -a tmux_cmd
|
||||
tmux_cmd=(command tmux)
|
||||
|
||||
eval $($tmux_cmd show-environment -s)
|
||||
}
|
||||
|
||||
# Use the completions for tmux for our function
|
||||
compdef _tmux _zsh_tmux_plugin_run
|
||||
# Alias tmux to our wrapper function.
|
||||
|
@ -87,3 +98,9 @@ if [[ -z "$TMUX" && "$ZSH_TMUX_AUTOSTART" == "true" && -z "$INSIDE_EMACS" && -z
|
|||
_zsh_tmux_plugin_run
|
||||
fi
|
||||
fi
|
||||
|
||||
# Automatically refresh tmux environments if tmux is running.
|
||||
if [[ -n "$TMUX" && "$ZSH_TMUX_AUTOREFRESH" == "true" ]] && tmux ls >/dev/null 2>/dev/null; then
|
||||
autoload -U add-zsh-hook
|
||||
add-zsh-hook preexec _zsh_tmux_plugin_preexec
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue