Use tmux or screen

screen or tmux is are terminal multiplexers that let you create multiple windows (and multiple panes in the case of tmux) and easily switch between them. This in itself is an extremely convenient feature to have on the console. They also allow you to keep the connection to a remote server alive, i.e. even if you disconnect from the server, you can resume your previous screen/tmux session when re-connect again.

I’m lazy so I only learn a few commands enough to get by; these commands are listed below.

Use screen instead. The control key of screen is Ctrl A
– screen -D -R : attach the active session (same as tmux attach)
– Ctrl – A – C : create new window
– Ctrl – A – 0, 1, … : switch to window number 0, 1 ,…

With tmux: the main hot key combination is Ctrl – B
– tmux attach : attach the active session (when there is only one)
– Ctrl – B – C : create a new window
– Ctrl – B – Shift – % : split the current pane vertically (into 2 panes)
– Ctrl – B – Shift – ” : split the current pane horizontally (into 2 panes)
– Ctrl – B – O : move around the panes
– Ctrl – B – 0,1,2,… : move to window number 0, 1 or 2
– Ctrl – B – [ : scroll mode  (q to exit )

I find several main advantages of tmux over screen (just using the out-of-the-box setting without any configuration — yes, I’m that lazy):

  • tmux can split a window into multiple panes — very useful when having a big display or when comparing things side-by-side.
  • tmux allows easy scrolling (with Ctrl – B – [ mode)
  • ctrl-A can still be used to move the cursor to the beginning of the current line (this happens an awful lot times due to the iterative nature of a data scientist’s work)
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s