Skip to content
Browse files
Experiment: move PWD and Git info from shell prompt to tmux pane titles
I'm just trying this on for size for now but it looks pretty:


- It reduces a bit of CLI clutter and gives a single, stable place to
  look for certain info.
- You can see infos even when running full-screen CLI programs.


- You lose a bit of contextual info when scrolling through the
  scrollback since you can't see the current directory or current Git
  hash next to the command you typed. In practice I haven't really
  missed it so far.
- Tmux does not wait for external commands to finish before drawing the
  UI so in order to view changes in near real-time this requires a fair
  bit of Zsh machinery to manually tell tmux to refresh after changing
  directories or running Git commands.
  • Loading branch information
whiteinge committed Oct 7, 2019
1 parent 7a902eb commit 984ee79371a497d3c575c7035cc3ad59067f2b89
Showing with 34 additions and 11 deletions.
  1. +14 −5 .tmux.conf
  2. +1 −5 .zsh_shouse_prompt
  3. +19 −1 .zshrc
@@ -101,16 +101,25 @@ set -g message-style "fg=black,bg=green"
setw -g window-status-bell-style "fg=black,bg=green,blink"
setw -g window-status-current-style "fg=blue,bg=white"

# Call out the active pane a bit more.
set -g pane-border-status top

set -g pane-border-style "fg=terminal,bg=terminal"
set -g pane-active-border-style "fg=black,bg=brightblack"

# Only show the pane title if it's a custom title.
# (The default hostname title is just noise.)
set -g pane-border-format "#[fg=black#,bg=brightblack]#{pane_id} #{pane_index}#{?pane_active,*,}#{?#{==:#{host},#{pane_title}},, #{pane_title}}"
# Show pwd, git, and tmux pane info in pane title.
# (Hides the default hostname #{pane_title}.)
set -g pane-border-format "\
#[fg=white,bg=black] \
#(~/bin/git-prompt -c tmux #{pane_current_path} && tmux refresh -S)\
#[align=right,fg=white,bg=black] \
#{pane_id} \
#{?#{==:#{host},#{pane_title}},, #{pane_title}} \

### Status bar.
set -g status-right-length 50
set -g status-right "#[fg=cyan]#h"
set -g pane-border-status bottom

# vim:ft=tmux
@@ -29,11 +29,7 @@ alias pr_bare="zstyle ':pr_nethack:' mode bare"

# Set default mode when zsh is first loaded (not every time prompt is drawn)
# Modes: full, compact, bare
if [[ $LINES -lt 5 ]] ; then
zstyle ":pr_nethack:" mode bare
zstyle ":pr_nethack:" mode compact
zstyle ":pr_nethack:" mode bare
zstyle ':pr_nethack:*' hooks pwd incog usr vcs venv jobs prompt
zstyle ':pr_nethack:*' pet "d" # A domestic animal, the _tame dog_ (_Canis familiaris_)
zstyle ':pr_nethack:*' pwd "%~"
20 .zshrc
@@ -303,8 +303,26 @@ function pman() {

# }}}

function refresh_tmux() {
tmux refresh -S

function last_command_was_git() {
[[ "$1" == git* ]] && _last_cmd_was_git=1

function refresh_tmux_on_git() {
if [[ "$_last_cmd_was_git" -eq 1 ]]; then
tmux refresh -S

# Run precmd functions
precmd_functions=( precmd_prompt )
preexec_functions=( last_command_was_git )
chpwd_functions=( refresh_tmux )
precmd_functions=( precmd_prompt refresh_tmux_on_git )

# Allow OS or environment specific overrides:
if [[ -r "$HOME/.zsh_customize" ]]; then

0 comments on commit 984ee79

Please sign in to comment.