Get window number of tmux.

This commit is contained in:
Gea-Suan Lin
2014-06-12 03:34:21 +08:00
parent aa7d5daea7
commit 85a0166c97

7
.zshrc
View File

@@ -40,12 +40,17 @@ autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:git*' formats "%b" zstyle ':vcs_info:git*' formats "%b"
precmd() { precmd() {
vcs_info if [[ ! -z "$TMUX" ]]; then
WINDOW=$(tmux display -p | awk '{print $2}' | awk -F: '{print $1}')
fi
if [[ -z "$WINDOW" ]]; then if [[ -z "$WINDOW" ]]; then
PS1=$'%{\e[m\e[G\e[K\e[32m%}%n%{\e[m%}@%{\e[36m%}%m%{\e[m%} [%{\e[32m%}%~%{\e[m%}] [%{\e[36m%}%D{%R}%{\e[m%}] ' PS1=$'%{\e[m\e[G\e[K\e[32m%}%n%{\e[m%}@%{\e[36m%}%m%{\e[m%} [%{\e[32m%}%~%{\e[m%}] [%{\e[36m%}%D{%R}%{\e[m%}] '
else else
PS1=$'%{\e[m\e[G\e[K\e[32m%}%n%{\e[m%}@%{\e[36m%}%m%{\e[m%} [%{\e[32m%}%~%{\e[m%}] [%{\e[36m%}%D{%R}%{\e[m%}/%{\e[36m%}W${WINDOW}%{\e[m%}]%{\e[0m%} ' PS1=$'%{\e[m\e[G\e[K\e[32m%}%n%{\e[m%}@%{\e[36m%}%m%{\e[m%} [%{\e[32m%}%~%{\e[m%}] [%{\e[36m%}%D{%R}%{\e[m%}/%{\e[36m%}W${WINDOW}%{\e[m%}]%{\e[0m%} '
fi fi
vcs_info
if [[ ! -z "$vcs_info_msg_0_" ]]; then if [[ ! -z "$vcs_info_msg_0_" ]]; then
PS1+=$'%{\e[1;30m%}(${vcs_info_msg_0_})%{\e[m%} ' PS1+=$'%{\e[1;30m%}(${vcs_info_msg_0_})%{\e[m%} '
fi fi