Aliases Link to heading

Add these useful aliases to your ~/.bashrc or ~/.profile:

alias copy="sudo rsync -aPh"
alias file-sizes="du -sh * | sort -h"
alias open-ports="lsof -i -P -n | grep LISTEN"
alias docker-cleanup="docker system prune -a -f"

tmux commands Link to heading

Installing Link to heading

  • MacOS: brew install tmux
  • Linux: apt install tmux

General Link to heading

  • Prefix: Ctrl + A (before all single key commands)
  • Edit Configuration: e

Session Link to heading

  • New Session: tmux or tmux new -s name or Ctrl + A + :new
  • Attach: tmux a or tmux attach or tmux a -t name
  • Detach: d
  • List/Change Session: s or tmux ls
  • Kill Session: x or tmux kill-session or tmux kill-session -t name
  • Kill All Sessions: tmux kill-session -a
  • Rename Session: $

Windows Link to heading

  • List Windows: w
  • New Window: c
  • Find Window: f
  • Kill Window: &
  • Switch Window: 1234, etc…
  • Resize Window: HJKL
  • Rename Window: ,

Panes Link to heading

  • Split Horizontally: ``
  • Split Vertically: ]
  • Swap Panes: o
  • Switch Pane: Arrow Keys
  • Kill Pane: x

vim commands Link to heading

File Link to heading

  • Save: :w
  • Quit: :q
  • Force Quit: :q!
  • Save & Quit: :wq
  • Save & Quit without sudo: :w !sudo tee %

Modes Link to heading

  • Insert Mode: i
  • Visual Mode: v
  • Visual Line Mode: V
  • Exit Mode: Ctrl + cEsc or Ctrl + [

Quick Modes Link to heading

  • Add Line Below + Insert Mode: o
  • Add Line Above + Insert Mode: O
  • Mode To End of Line + Insert Mode: A
  • Move To Beginning of Line + Insert Mode: I
  • Move One Letter Right + Insert Mode: a
  • Delete Single Character + Insert Mode: s
  • Delete Rest of Line + Insert Mode: C
  • Delete Rest of Line + Insert Mode Properly Indented: S

Movement Link to heading

  • Up, Down, Left, Right: jkhl
  • Jump Forwards & Back by 1 Word: w & b
  • Jump to Top/Bottom of File: gg / G
  • Jump Up/Down Paragraphs: { / }
  • Jump Up/Down Page: Ctrl + u / Ctrl + d
  • Jump to Specific Line: :_ or _G
  • Jump to Next Occurence of Selected Word: ``
  • Jump Forward/Back to Next Occurence of Specified Character _ : f_ / F_ (; and , to go through results)
  • Jump Forward/Back to but Not On Next Occurence of Specified Character _ : t_ / T_ (; and , to go through results)
  • Search: / (n and N to go through results)

Editing Link to heading

  • Select All: ggVG
  • Yank Line: yy
  • Paste Line Below: p
  • Paste Line Above: P
  • Delete Line: dd (goes to register so p will paste deleted line)
  • Delete Multiple Lines: _dd
  • Delete Rest of Line: D
  • Delete Word: :cw
  • Delete Character: x
  • Undo: u
  • Redo: Ctrl + r
  • Increase selected number(s) by 1: Ctrl + a

Selecting Link to heading

  • Highlight Selected: Shift + v (can expand with jkh, & l)
  • Highlight Line: Shift + V (can expand with jkh, & l)

Bulk Editing Link to heading

  • Edit Multiple Lines: Ctrl + v > Select lines > c > make changes to one line > esc to commit changes
  • Have each line increment number by 1: First set each number to 00 on each line > Select 00 in all lines with Ctrl + v > g > Ctrl + a (Remember Ctrl + a > a on mac with custom tmux modifier)

Note: If numbers are skipping from 7 to 10 or including another 0 before double digit numbers, run :set nrformats-=octal before doing the command above.

  • Search & Replace: :%s/foo/bar/gc
    • Wildcard in search and replace: .*
    • Search and replace everything in brackets: :%s/\[.*]/bar/gc

ranger commands Link to heading

  • Open Ranger: ranger or mac shortcut Cmd + F
  • Navigate: HJKL or arrow keys like a noob
  • Show/Hide Hidden Files: zh
  • Select files: spacebar
  • Select All Files in Dir: v
  • Bulk Rename: :bulkrename
  • Quit: q or Q or :q

Quitting returns shell to same directory with this bash alias:

alias ranger='ranger --choosedir=$HOME/.rangerdir; LASTDIR=`cat $HOME/.rangerdir`; cd "$LASTDIR"'

Other useful tools I use Link to heading

  • fzf: Best search tool for mac/linux.
  • barrier: Use one computer to control another like a second monitor.