← Back to Upcase

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 https://github.com/Goles/Battery

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