It can be very helpful when working with a server through SSH. Instead of opening a terminal and connecting to your server every time you nedd another terminal, you can setup your server to run Byobu or tmux at the beginning of your session and have as many terminals as you need. Byobu also keeps terminal sessions alive after detaching from them.
Byobu is an enhancement that connects to and uses Screen or tmux (you choose), but offers useful statistics and easy-to-use hotkeys for the basic commands.
apt-get install byobu.
Else take a look at http://byobu.co/downloads.html
Configure Ubuntu to run Byobu from the beginning
Feel free to change anything.
The important setting to change is: “Byobu currently launches at login (toggle on)“. Select that and press return.
Now you can go back to the menu and exit byobu-config (tab to the exit choice and hit return).
Resume previous sessions
byobu –r session_title
Byobu has easy keybindings that use the function keys:
- F2: Create a new window
- F3: Move to previous window
- F4: Move to next window
- F5: Reload profile
- F6: Detach from this session
- F7: Enter copy/scrollback mode
- F8: Re-title a window
- F9: Configuration Menu, can also be summoned by Ctrl+a, Ctrl+@
- F12: Lock current session
How detaching works or How to maintain a session
Perform a short demo. Issue the command:
Now exit the session by pressing F6 to detach from Byobu and then run: exit.
Now SSH back into your machine. You can notice that the echo hello command is still on the screen.
Detaching does not end your session, it gives you access to another session. That means you can log in, run a long running task, and then detach and come back later when you;ve finished the task.
Note for vim users:
You might find now a strange behaviour when using Ctrl-Left and Ctrl-Right keys to skip words using vim and also other programs.
The best solution I found was:
echo ':set term=xterm' >> ~/.vim/vimrc
echo 'unbind-key -n C-Left' >> ~/.byobu/keybindings.tmux echo 'unbind-key -n C-Right' >> ~/.byobu/keybindings.tmux
echo 'set-window-option -g xterm-keys on' >> ~/.byobu/.tmux.conf echo "set -g terminal-overrides 'xterm*:smcup@:rmcup@'" >> ~/.byobu/.tmux.conf