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
ortmux new -s name
orCtrl + A + :new
- Attach:
tmux a
ortmux attach
ortmux a -t name
- Detach:
d
- List/Change Session:
s
ortmux ls
- Kill Session:
x
ortmux kill-session
ortmux 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:
1
,2
,3
,4
, etc… - Resize Window:
H
,J
,K
,L
- 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 + c
,Esc
orCtrl + [
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:
j
,k
,h
,l
- 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
andN
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 sop
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 withj
,k
,h
, &l
) - Highlight Line:
Shift + V
(can expand withj
,k
,h
, &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 > Select00
in all lines withCtrl + v
>g
>Ctrl + a
(RememberCtrl + 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
- Wildcard in search and replace:
ranger commands Link to heading
- Open Ranger:
ranger
or mac shortcutCmd + F
- Navigate:
H
,J
,K
,L
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
orQ
or:q
Quitting returns shell to same directory with this bash alias:
alias ranger='ranger --choosedir=$HOME/.rangerdir; LASTDIR=`cat $HOME/.rangerdir`; cd "$LASTDIR"'