Tmux PWD Command-Line Panel
There are several ways to do this. I do it myself. The easiest and most customizable way is to set a global variable that tmux can access.
First add this to your .bashrc or .zshrc file to set the PWD variable after each prompt:
# create a global per-pane variable that holds the pane PWD export PS1=$PS1'$( [ -n $TMUX ] && tmux setenv -g TMUX_PWD_$(tmux display -p "#D" | tr -d %) $PWD)'
Now create a script that displays this variable, for example ~/bin/display_tmux_pane_pwd.sh :
#!/bin/bash tmux showenv -g TMUX_PWD_$(tmux display -p "#D" | tr -d %) | sed 's/^.*=//'
All that remains is to add this to the satis bar in .tmux.conf :
set -g status-left '#(~/bin/display_tmux_pane_pwd.sh)'
It may take some time to update after switching panels, so you can change this with this command. By default, it is updated every 15 seconds, it will take 5 seconds. Change it as you like.
set -g status-interval 5
Tmux-Pane PWD in other programs
Sometimes itβs useful to open a panel or window and immediately start the program instead of loading another shell (for example, tmux new-window vim ). Thus, when you close this program, you also close the window. Unfortunately, the way I describe above requires a hint for translating PWD status. However, in many programs you can get around this fairly easily. Here is an example of what is in my .vimrc file so that vim updates the status of PWD whenever it changes buffers.
if exists("$TMUX") " Get the environment variable let tmux_pane_name_cmd = 'tmux display -p \#D' let tmux_pane_name = substitute(system(g:tmux_pane_name_cmd), "\n", "", "") let tmux_env_var = "TMUX_PWD_" . substitute(g:tmux_pane_name, "%", "", "") unlet tmux_pane_name tmux_pane_name_cmd function! BroadcastTmuxCwd() let filename = substitute(expand("%:p:h"), $HOME, "~", "") let output = system("tmux setenv -g ".g:tmux_env_var." ".l:filename) endfunction autocmd BufEnter * call BroadcastTmuxCwd() endif
scicalculator
source share