Terminal Cockpits With Tmux
Publish date: Jul 18, 2019
Last updated: Apr 22, 2020
Last updated: Apr 22, 2020
- tmux
- terminal multiplexer to quickly switch to app
- tmux-session for applications
- sample
Use cases
- watch all your repo status - call it repo dashboard
watch 'git status'
- pair-programming and share terminal
Tmux scripting
- various projects may have various setups
- New tmux window for each project
Listing, renaming and killing windows and panes
all keyboard shortcuts are run inside tmux session with PREFIX
Sessions
s sessions list
$ rename session
:new<CR> new session
Windows / tabs
w windows list
, rename window
c new window
f find window
& kill window
n next window switch
p previous window switch
<number> jump to window with number - number starts from 0
Misc
? list shortcuts
d detach
t time - display clock
: prompt
q display pane numbers for a short while
# Silently run processes in tmux in background
tmux new-session \
-s session-name \
-n window-name \
-d htop
# To attach use
tmux attach -t session-name
- Only creates session and doesn’t attach to them. Alias
new
- To detach new-session from current terminal window, unless specified
- Linux command to run inside tmux window
- alias for
attach-session
Session Management
tmux new -s session_name
- creates a new tmux session named session_name
tmux attach -t session_name
- attaches to an existing tmux session named session_name
tmux switch -t session_name
- switches to an existing session named session_name
tmux list-sessions
- lists existing tmux sessions
tmux detach (prefix + d)
- detach the currently attached session
How to scroll in tmux
CTRL + b then [ then you can use your normal navigation keys to scroll around (eg. Up Arrow or PgDn). Press q to quit scroll mode.
Alternatively you can press Ctrl-b PgUp to go directly into copy mode and scroll one page up (which is what it sounds like you will want most of the time)
Window Management
- tmux new-window (prefix + c)
- create a new window
tmux select-window -t :0-9 (prefix + 0-9)
- move to the window based on index
tmux rename-window (prefix + ,)
- rename the current window
tmux split-window (prefix + ")
- splits the window into two vertical panes
tmux split-window -h (prefix + %)
- splits the window into two horizontal panes
tmux swap-pane -[UDLR] (prefix + { or })
- swaps pane with another in the specified direction
tmux select-pane -[UDLR]
- selects the next pane in the specified direction
tmux select-pane -t :.+
- selects the next pane in numerical order
tmux list-keys
- lists out every bound key and the tmux command it runs
tmux list-commands
- lists out every tmux command and its arguments
tmux info
- lists out every session, window, pane, its pid, etc.
tmux source-file ~/.tmux.conf
- reloads the current tmux configuration (based on a default tmux config)
swap
sudo swapon --show
sudo swapon --summary
sudo fallocate -l 4G /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
free -h
cat /proc/sys/vm/swappiness
cat /proc/swaps
- Displays SWAP on system
How do I add fresh new swap?
Turn swapon
and swapoff
from GParted
tool
Terminal Applications
Which tools languages to use? NOde, python, rust, bash? How to choose?
- Node.js vs Python Comparison: Which Solution to Choose for Your Next Project?
- Domain specific Languages
- Perl - text processing
- awk - terminal reporting
- Identify the components you need
- Colored fonts, texts -
chalk
- Progress bars
- Dialog boxes, input fields
- PAssword text
- parsing command line arguments
- abstraction for internal CLIs (e.g.
readline
)
- Colored fonts, texts -
My Projects
Footnotes
[^2]: