Tmux Part 2: Configuration

Configuration Configuration Interfaces Tmux has 3 interfaces for running commands and making configurations: Tmux executable - This is the tmux command available in your shell. All commands can be run directly against this, but note that any c...
This is a companion discussion topic for the original entry at https://thoughtbot.com/upcase/videos/tmux-configuration

we configure tmux to let let the window index start at 1

set -g base-index 1

but the panes still start there index at 0.

I found out that the panes can also start their index at one by adding

setw -g pane-base-index 1

to the .tmux.conf file

Hi! Iā€™m having trouble to get two of the bindings to work.

  • ā€˜bind-key C-s send-prefixā€™ nor ā€˜bind-key -r C-s send-prefixā€™ will let me go forward when I do ā€˜C-s C-sā€™ or just ā€˜C-sā€™ respectively.
  • 'set-option -g status-keys ā€œemacsā€ allows me to go to the end of the line when I do ā€˜C-eā€™ but not when I do ā€˜C-aā€™

How should I go about troubleshooting this?

Hello @theresaluu As a start, you can check the output of the tmux list-keys command for the various modes. Below is the output for my configuration which is largely as shown in the screencasts. Yours should match:

$ tmux list-keys | grep -E '(C-s|C-a)'
#=> bind-key -r     C-s send-prefix

$ tmux list-keys -t emacs-edit | grep -E '(C-s|C-a)'                                                                                     [2.2.2p95]
#=> bind-key -t emacs-edit    C-a start-of-line
1 Like

Sometime you get disconnected from internet. It would be useful to use the is-online package
set-option -g status-right " #(battery -t) #(is-online) #(date '+%a, %b %d - %I:%M') "

@arbaaz thanks for sharing! Iā€™ve actually been looking for something like this for a while. For anyone else looking to add this, youā€™ll want to install the is-online-cli globally with npm install -g is-online-cli.

@christoomey hey great video! btw I still donā€™t understand what is the benefit of using repeat C-s? can you elaborate more

Hey @christiansakai, thanks for the kinds words!

By default, in a shell with readline support, C-s is already bound to an action, specifically forward-incremental-history-search (the oposite of C-r).

Since we configure tmux to use C-s, we lose the ability to do forward-incremental-history-search. The configuration I demonstrate allows us to get the behavior back by pressing C-s twice.

Hope that helps, but please let me know if you have any additional questions.

@christoomey gotcha! thanks for replying. Really great video! Iā€™ve been looking for this kind of content for a while. There are a lot of article about tmux vim workflow but thereā€™s no tutorial on it. Please continue to add more content along this topic!

Just because Iā€™m a doperinoā€¦to get the battery indicator to workā€¦ I first had to run the following terminal commandsā€¦

$ brew tap Goles/battery
$ brew install battery
$ brew install spark

Itā€™s all documented on the github page GitHub - Goles/Battery: Battery is a bash script to display your Laptop's battery status on the terminal.

for anyone having issues with setting the default-terminal to 256 colors, this post helped me fixed it.

In the end, because I use bash, I had to add to my bash profile export TERM=xterm-256color and everything started to work.

Hi,

I have C-h,j,k,l mapped in Vim to move between panes. Now that Iā€™ve setup the same for tmux, I can no longer move between panes in vim. The tmux is taking somehow those mappings over vim. I thought it should be the other way around. Let me know how to fix this. The desired behavior is: when in vim all keybinds go to vim, when in tmux (without vim) same keybinds go to tmux.

Thank you.

In the fourth video on Tmux and Vim Integration I cover the vim-tmux-navigator plugin which handles this. Enjoy!

Just a note that it seems in the latest version of tmux (currently 2.9a), the \ escape doesnā€™t seem to work anymore. bind-key r source-file ~/.tmux.conf ; display-message "~/.tmux.conf reloaded" should suffice.

Vim-like keys for navigating between panes are nice

bind-key -n C-l select-pane -R

But I canā€™t use Ctrl+L now to clear console output. Do you just type clear in console or have some other useful bind?

Hi @gavvvr, check out this section in the readme which describes a key mapping you can use to get clear screen back.

1 Like

This week at work I connected to CentOS 5.3 over ssh inside of tmux pane. I had troubles with executing clear and htop.

[x@x-qa ~]$ htop
Error opening terminal: screen-256color.
[x@x-qa ~]$ clear
'screen-256color': unknown terminal type.

Do not know why this happens (did not have problems with newer CentOS nodes). The following command to connect to that old CentOS node:
TERM=xterm ssh x@x-qa fixes the above problem, but I still do not understand why. Would be great to get some explanation on what TERM values mean

I was having issues with my backspace key to fix it I needed my .tmux line to state the below.
set -g default-terminal ā€œxterm-256colorā€
EDIT: the above is wrong if you are having issues with backspace functionality Try:
echo $TERM
if it states xterm-256color that is the issue. Enter:
TERM=screen
note this need to be done within tmux