Show Menu
Cheatography

Common Terminal Commands Cheat Sheet (DRAFT) by

A list of commands I commonly use with Git, Tmux and Vim

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Terminal

# grep -lir '<s­ear­ch>' <di­r>
Find text in files
# grep -rn '<s­ear­ch>' <di­r>
... with line number and preview
# sed -n 20,30p somefi­le.txt
show lines in a file

Git

# git checkout -- .
Undo my changes
# git commit -am '...'
if you haven't added any new files and you want to commit
# git remote set-url origin http:/­/<U­SER­NAM­E>@­sta­sh.e­xa­mpl­e.c­om/­rep­o.git
Reset the origin

Git - working with others

# git add -A .
# git commit -m '...'
# git pull
// solve conflicts
# git push
(When your working with someone on git)

Vim

# vim ...
open file
Esc :q
quit
Esc :q!
shit I've done something wrong
i
edit file
Esc :w
save changes
Esc :x
save and exit
dd
delete line
dG
delete ALL lines
Esc :e
reload file
/...
search for text
* (on a word)
search for that word
Esc :noh
clear search
Esc :set autoread
Live reloads
Copy Text
v
start copy
y
end copy
(d)
(cut text)
p
paste
for
:find
to work include
:set path=.,­/u­sr/­inc­lud­e,,**
in your
~/.vimrc
file
 

Linux

Apache Logs
/var/l­ogs­/httpd/

Tmux

# tmux ls
show sessions
# tmux a -t ...
attache to a session
# tmux new -s ...
new session
# tmux kill-s­ession -t ...
kill session
Ctrl+a d
exit tmux
Panels
Ctrl+a -
split panel horizontal
Ctrl+a |
split panel Vertically
Ctrl+a x
close panel
Ctrl+a z
Full screen panel
Alt+<up arrow>
move to panel above
Alt+<... arrow>
...
Panel - Scroll Mode
Ctrl+a [
enter scroll mode
<... arrow>
scroll around
q
quit scroll mode
Windows
Ctrl+a c
new window
Ctrl+a &
delete window
Ctrl+a n
next window
Ctrl+a p
previous window
Ctrl+a '
rename window
Copy Text
Ctrl+a [
enter copy mode
Ctrl+<­spa­ce>
start copy
Alt+w
stop copy
Ctrl+a ]
paste text
Ctrl+a
only works if you have
set -g prefix C-a
and
bind C-a send-p­refix
and
unbind C-b
in your
~/.tmu­x.conf