From 85a0166c97d29cf5b6131705a71e35bd8b2f1fbe Mon Sep 17 00:00:00 2001 From: Gea-Suan Lin Date: Thu, 12 Jun 2014 03:34:21 +0800 Subject: [PATCH] Get window number of tmux. --- .zshrc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.zshrc b/.zshrc index a83a7fc..20c3b23 100644 --- a/.zshrc +++ b/.zshrc @@ -40,12 +40,17 @@ autoload -Uz vcs_info zstyle ':vcs_info:*' enable git zstyle ':vcs_info:git*' formats "%b" precmd() { - vcs_info + if [[ ! -z "$TMUX" ]]; then + WINDOW=$(tmux display -p | awk '{print $2}' | awk -F: '{print $1}') + fi + 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%}] ' 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%} ' fi + + vcs_info if [[ ! -z "$vcs_info_msg_0_" ]]; then PS1+=$'%{\e[1;30m%}(${vcs_info_msg_0_})%{\e[m%} ' fi