I am new to tmux and I am trying to edit my tmux.conf file to have the left side of the status bar reflect:
[SessionName] [CurrentPane] [CurrentWorkingDirectory]
I am able to display the SessionName
and CurrentPane
. However I can't get to display the CurrentWorkingDirectory
.
I've tried several #(shell command)
options:
#(tmux select-pane -t :.#P; pwd)
:
But this prints some other $PWD variable which does NOT reflect
the current directory of the bash session in the current pane.
#(tmux select-pane -t :.#P; tmux send-keys pwd Enter)
Firstly, although it did print the CurrentWorkingDirectory
if I'm
in a terminal. It prints this in the terminal and NOT in the status
bar like how I want it. Secondly, It entered "pwd Enter" every 15
seconds whether or not I was in a terminal, which was a hassle to
reverse if your not as quick (like I am).
I've tried these options but to no avail, is it possible to do what I want? and how?
Tmux uses the keybinding 'Prefix' followed by 'Ctrl+o' to cycle around the panes. When you use this key-binding for the first time, it moves the pane in one position clockwise.
Switching between panes To get from one pane to another, press Ctrl+B followed by O (as in other).
How to toggle between light-background and dark-background themes in tmux. Now Ctrl + b Shift + t toggles between light and dark mode. You might want to add more lines to the script to change other options like pane-border-style and pane-active-border-style (the colours of the pane borders) between light and dark mode.
There is a variable for that, which doesn't seem to be in the manpage but is mentioned in the development version. For me, it works in the 1.8 release of tmux.
set -g status-left "#{pane_current_path}"
Note that it also works when you put it in the window-status. Each window status will mention respective working directories.
setw -g window-status-format "#{pane_current_path}".
I'm not sure how to do this in bash, but in zsh, there's a hook that gets run before every command. In your .zshrc:
precmd () {
tmux set -qg status-left "#S #P $(pwd)"
}
This will run that tmux
command everytime you run a command. Hope this helps. Since bash
doesn't have a precmd
, I'm not sure how to do this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With