Arrow keys not working in tmux from PuTTY


I SSH into a Ubuntu computer from a Windows computer using PuTTY. I run tmux (actually byobu which runs tmux underneath) and at a shell inside tmux I find that the left and right arrow keys do not work. They are actually detected as shift+left and shift+right arrow keys inside tmux.


This problem has been discussed here. One of the suggested solutions was to add set enable-keypad on to ~/.inputrc. That did not seem to work for me.

However, the above bug report also mentioned that this was a bug in tmux and it was fixed in tmux 2.4. So, I used this tmux PPA and updated the tmux 2.1 shipping in Ubuntu 16.04 to a tmux 2.6. The arrow key problem disappeared.

How to update environment variable of existing Tmux session


I use Byobu (which is a wrapper on Tmux) to maintain shell sessions on the many servers I login to. I connect, disconnect and reconnect to the same Tmux sessions on these servers. When I reconnect back to an existing Tmux session, a new value is assigned to the DISPLAY environment variable. If I create a new Tmux session, by opening a new split or tab, then Tmux sets the new DISPLAY value correctly for that session. However, existing Tmux sessions have their old DISPLAY value which gives the familiar cannot open display error. I can find out the new DISPLAY value and set it manually in the existing session, but that is cumbersome.


I found a simple solution to this problem. Whenever I SSH to a server, I save the new DISPLAY assigned to this server in a .display.txt file in the home directory. For example, this can be done in .bashrc:

echo $DISPLAY > ~/.display.txt

To pick up the new DISPLAY value from this file in existing sessions, create a shell alias or function that you can call when you realize that the environment variable is wrong.

For example, for Fish shell, I added a ~/.config/fish/functions/ file with these lines:

function set_display
    set --export DISPLAY (cat ~/.display.txt)

When I need to update DISPLAY, I just call set_display at the shell! πŸ™‚

Tried with: Byobu 5.74, Tmux 1.8 and Fish 2.2.0

How to make Byobu responsive on large text output


I use Byobu on remote computers which I have connected to using SSH. I typically use many vertical and horizontal splits and tabs. If a program in my current pane starts writing a huge amount of text to the terminal, Byobu becomes unresponsive. That is, I cannot switch panes or even kill the runaway command!


Byobu is just a wrapper on Tmux, so we need to fix this problem in Tmux. Whenever Tmux gets a trigger sequence (like newline), it modifies the pane. If it is caught in a loop of modifying the pane, it will not get a chance to process input from the user, like control sequences to switch panes or Ctrl+C.

Thankfully, Tmux has a rate limiting feature and it is active by default. We just need to tinker with its values to make our user experience more responsive.

When the rate of triggers is above a threshold, we can ask Tmux to redraw the pane instead of just modifying it. This redraw also gives it a chance to process user input at that moment. This trigger threshold is set in the c0-change-trigger configuration option. The default is 250. That is, only if the number of trigger sequences is more than 250 per millisecond, Tmux will switch to redrawing instead of modifying the pane. To make Tmux (or Byobu) responsive, we need to lower this trigger threshold.

This solves the first problem, that is you will be able to switch away from the pane where text is being vomited. But if you want to comfortably type in the other panes, you cannot. This is because the vomiting pane is being redrawn too frequently. To fix this, we need to increase the redraw interval. This is controlled by the c0-change-interval configuration option and its default value is to redraw every 100 milliseconds.

To make Tmux responsive, I added these lines to my ~/.byobu/.tmux.conf modifying the above two options:

set -g c0-change-trigger 20
set -g c0-change-interval 1000

Tried with: Byobu 5.77, Tmux 1.8 and Ubuntu 14.04

How to run program in background using Byobu

When running a training program, that might take hours to complete, I like to run it in the background. However, it should keep running even if I kill my current shell. I should be able to bring it back to the foreground and check its console output and then send it back to background. I should be able to do this any number of times.

The solution that fulfilled these requirements was to run the program in a new Byobu session. This is how I do it:

  • From my current shell, I launch a new Byobu session and start the program I want to run from its shell:
$ byobu
$ ./my-program
  • To detach from this Byobu session, just press Ctrl+a followed by d.

  • To re-attach to the Byobu session and check the progress of my program, invoke Byobu again from any terminal or shell.

The advantage of this setup is that Byobu is not the child of my shell, but rather of the desktop lightdm process. So, it will keep running even if my terminal is hung or killed. It also enables me to see the console output of the program anytime I want.

Tried with: Byobu 5.74, TMux 1.8 and Ubuntu 14.04

How to install Byobu on Cygwin

Byobu is a user friendly terminal multiplexer built around tmux.

There is no byobu package in Cygwin, but installing it from source is easy:

  • Install tmux and make using the Cygwin package installer.

  • Download the latest release of Byobu from here and unzip it.

  • Configure by providing it the directory where you want it to be installed and then make install it:

$ ./configure --prefix="$HOME/installs/byobu"
$ make
$ make install
  • Add the installed bin directory to your PATH environment variable at the shell or permanently in your bashrc:
$ export PATH="$HOME/installs/byobu/bin:$PATH"

You can now run byobu at the shell. You will notice that there will be some errors when it looks for Linux programs that are either not installed or not available on Cygwin. Also, the configuration user interface does not appear since that needs python-newt which is not available for Cygwin. Some of the function key combinations might also not work cause it is Windows.

Tried with: Byobu 5.125 and Cygwin 2.10


ByobuΒ is a program that makes using terminal multiplexers really easy. A terminal multiplexer is like a windowing system for console programs. Byobu uses tmux by default, but can be configured to use GNU screen too.

Byobu allows you have many console windows or programs running at the same time. You can detach from Byobu and later restore the session, with all your terminals and programs running intact. This is similar to hibernating and restarting an OS back.


  • When opened, Byobu opens with your default shell. The bottom line of Byobu is like a taskbar and shows currently open windows (or tabs). You can see the default window (or tab) numbered 0 there.
  • To open a new session named foo, use the command: byobu -S foo

Keyboard shortcuts

Byobu uses the function keys for almost all its operations.

  • F2: Open a new window or tab. This means that a new shell session is opened in that window. This window is numbered 1, as seen at the bottom.
  • F3 or F4: Switch forward and backward between open windows.
  • F6 or Ctrl+A d: Detach from Byobu. Puts you back at the shell. All the windows and the shells inside them are still running. You get back to them whenever you want.
  • F7: Toggle mode to scroll through history. Once in this mode, use cursor keys or Page Up or Page Down to scroll through history. To search back or forward in the history, use slash or question mark (just like in Vim). Press Enter to get out of this mode.
  • F8: Rename the current window. The name is shown at the bottom of each window. This is very useful to distinguish work you are doing in each window.
  • Ctrl + F2: Create a vertical split window
  • Shift + F2: Create a horizontal split window
  • Shift + F3 or Shift + F4: Switch forward and backward between split windows
  • F9: Change the settings using its inbuilt Curses GUI dialog.
  • Alt + F12: Toggle mouse support. More details in this post.
  • Shift + F12: Toggle function keys. This is useful when you want to use the function keys in a terminal application.

You can see these keyboard shortcuts defined in the /usr/share/byobu/keybindings/f-keys.tmux file.

Tried with: Byobu 5.77 and Ubuntu 14.04