Pi-Commands

Auto Update

sudo apt update        # Fetches the list of available updates
sudo apt upgrade       # Installs some updates; does not remove packages
sudo apt full-upgrade  # Installs updates; may also remove some packages, if needed
sudo apt autoremove    # Removes any old packages that are no longer needed
sudo bash -c 'for i in update {,full-}upgrade auto{remove,clean}; do apt-get $i -y; done'

Tmux

Tmux is a terminal multiplexer that allows you to manage multiple terminal sessions within a single window. Here is a concise cheatsheet to help you get started with Tmux and its various commands and shortcuts.

General Commands

  • Start a new sessiontmux new -s session_name
  • Attach to an existing sessiontmux attach -t session_name
  • List all sessionstmux ls
  • Detach from the current sessiontmux detach

Windows

  • Create a new windowtmux new-window
  • Switch to the next windowtmux next-window
  • Switch to the previous windowtmux previous-window
  • List all windowstmux list-windows

Panes

  • Split window verticallytmux split-window -v
  • Split window horizontallytmux split-window -h
  • Navigate between panestmux select-pane -[UDLR]
  • Resize panestmux resize-pane -[UDLR] [size]
  • Close the current panetmux kill-pane

Copy and Paste

  • Enter copy modetmux copy-mode
  • Start selectionSpace
  • Copy selectionEnter
  • Paste selectiontmux paste-buffer

Scrolling

  • Enter scroll modetmux scroll-mode
  • Scroll up/downUp/Down Arrow

Status Bar Customization

  • Set status bar justificationtmux set -g status-justify [left|centre|right]
  • Set status bar left contenttmux set -g status-left ‘…’

Mouse Support

  • Enable mouse supporttmux set -g mouse on

Scripting Tmux

  • Start a new session and run commands in multiple panestmux new-session -d -s session1 tmux rename-window ‘my window’ tmux send-keys ‘echo “pane 1″‘ C-m tmux split-window -h tmux send-keys ‘echo “pane 2″‘ C-m tmux split-window -h tmux send-keys ‘echo “pane 3″‘ C-m tmux select-layout even-horizontal tmux attach-session -t session1
tmux start-server      # Start Tmux
tmux ls                # List sessiona
tmux kill-session -t SESSIONNAME
tmux new -s myname     # start new with session name
tmux a -t myname       # attach to named 

# create two new sessions SES1 and SES2 and detach them.(-d -s is important)
tmux new-session -d -s SES1
tmux new-session -d -s SES2



Sessions
:new<CR>  new session
s  list sessions
$  name session
Windows (tabs)
c           new window
,           name window
w           list windows
f           find window
&           kill window
.           move window - prompted for a new number
:movew<CR>  move window to the next unused number
Panes (splits)
%  horizontal split
"  vertical split

o  swap panes
q  show pane numbers
x  kill pane
⍽  space - toggle between layouts

C-o’ Rotate the panes in the current window forwards.
C-z’ Suspend the tmux client.
!’ Break the current pane out of the window.
“‘ Split the current pane into two, top and bottom.
#’ List all paste buffers.
$’ Rename the current session.
%’ Split the current pane into two, left and right.
&’ Kill the current window.
” Prompt for a window index to select.
,’ Rename the current window.
-‘ Delete the most recently copied buffer of text.
.’ Prompt for an index to move the current window.
0 to 9′ Select windows 0 to 9.
:’ Enter the tmux command prompt.
;’ Move to the previously active pane.
=’ Choose which buffer to paste interactively from a list.
?’ List all key bindings.
D’ Choose a client to detach.
[‘ Enter copy mode to copy text or view the history.
]’ Paste the most recently copied buffer of text.
c’ Create a new window.
d’ Detach the current client.
f’ Prompt to search for text in open windows.
i’ Display some information about the current window.
l’ Move to the previously selected window.
n’ Change to the next window.
o’ Select the next pane in the current window.
p’ Change to the previous window.
q’ Briefly display pane indexes.
r’ Force redraw of the attached client.
s’ Select a new session for the attached client interactively.
L’ Switch the attached client back to the last session.
t’ Show the time.
w’ Choose the current window interactively.
x’ Kill the current pane.
{‘ Swap the current pane with the previous pane.
}’ Swap the current pane with the next pane.
~’ Show previous messages from tmux, if any.
Page Up’ Enter copy mode and scroll one page up.
Up, Down’
Left, Right
Change to the pane above, below, to the left, or to the right of the current pane.
M-1 to M-5
Arrange panes in one of the five preset layouts: even-horizontal, even-vertical, main-horizontal, main-vertical, or tiled.
M-n’ Move to the next window with a bell or activity marker.
M-o’ Rotate the panes in the current window backwards.
M-p’ Move to the previous window with a bell or activity marker.
C-Up, C-Down
C-Left, C-Right
Resize the current pane in steps of one cell.
M-Up, M-Down
M-Left, M-Right

Tmux Cheat Sheet