One of the things i hate in tmux
is, its copy mode. I prefer how a simple terminal works, but still i want the advantages of using tmux
, so i have to cope with it. Thus i wanted to change its copy mode key bindings and do anything else that will help to remember them and know that i am in copy mode.
I will not discuss the key binding, cause it's something you can search on the Net and find many posts and articles. But changing the status bar and adding some information, when in cop mode, is not something well documented. Lets see how to do it with my statusbar configuration as an example.
My statusbar, when running tmux looks like this:
The line in the .tmux.conf that makes the statusbar to look like this is the following...
set -g status-fg colour240
set -g status-bg colour233
#set -g status-left-bg colour233
#set -g status-left-fg colour243
set -g status-left-length 40
set -g status-left "#{?client_prefix,#[fg=colour255]#[bg=colour31]#[bold] #S #[fg=colour31]#[bg=colour233],#[fg=colour232]#[bg=colour255]#[bold] #S #[fg=colour255]#[bg=colour233]}"
#set -g status-right-bg colour233
#set -g status-right-fg colour243
set -g status-right-length 100
set -g status-right "#{net_speed} #[fg=colour236,bg=colour233]#[fg=colour255,bg=colour236] %H:%M #[fg=colour233,bg=colour236]#[fg=colour255,bg=colour233,bold] #{session_attached} #[fg=colour255,bg=colour233]#[fg=colour233,bg=colour255] #(whoami)@#[fg=colour232,bg=colour255,bold]#H "
As you may see, when in normal mode, in the status bar, there is a short text, that tells us, how to go into copy mode, by pressing the prefix key with F5, which is my preferred way. Now, i want to see the rest of the keys, that are necessary to use, when in copy mode. To do that, in the status-right
line, i added the following string:
#{?pane_in_mode,#[fg=colour232]#[bg=colour202]s select|R rec.toggle|Enter accept|Esc cancel,F5 Copy}
So the above part of my .tmux.conf file will be like this:
set -g status-fg colour240
set -g status-bg colour233
#set -g status-left-bg colour233
#set -g status-left-fg colour243
set -g status-left-length 40
set -g status-left "#{?client_prefix,#[fg=colour255]#[bg=colour31]#[bold] #S #[fg=colour31]#[bg=colour233],#[fg=colour232]#[bg=colour255]#[bold] #S #[fg=colour255]#[bg=colour233]}"
#set -g status-right-bg colour233
#set -g status-right-fg colour243
set -g status-right-length 100
set -g status-right "#{?pane_in_mode,#[fg=colour232]#[bg=colour202]s select|R rec.toggle|Enter accept|Esc cancel,F5 Copy}#{net_speed} #[fg=colour236,bg=colour233]#[fg=colour255,bg=colour236] %H:%M #[fg=colour233,bg=colour236]#[fg=colour255,bg=colour233,bold] #{session_attached} #[fg=colour255,bg=colour233]#[fg=colour233,bg=colour255] #(whoami)@#[fg=colour232,bg=colour255,bold]#H "
...and the final result.
I can now, always have a reference for what the keys to my copy mode are set and don't look into the config file or anywhere else. I hope you find this useful, as i am :)