-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalwaysforget.txt
141 lines (129 loc) · 6.43 KB
/
alwaysforget.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# Pat's command list cheatsheet
# Misc
locate <file to lookup>#Searches whole computer for a file
cd - # Going back to previous directory
wc -l <file> # Gives the number of lines in a file
lsof -i :<port_num> # Lists any processes running on a given port
ls -lh # lists file size with sig digits
ls -a # Hidden files as well
cp -r <source> <destination> # copy directories from one place to another
tar -zxvf <tarfile> # Untarring a tar into current directory
pydoc <thing to lookup>
find <directory_to_search> -name "<regex>" # Searches a directory for a file
# Omit first param to search curr dir
# Compression
zip <zip_name> <list of files to be included>
zip -r <zip_name> <list of files to be included>
# Git
git fetch # Gets info from remote repo (aka origin)
git pull # Combination of `git fetch` and `merge` from origin
git reset <filename> # Removes the file from staging area
--hard <branch> # Use this to nuke any local changes you have. You can
Use this to sync with HEAD or with origin (remote)
--soft # Used when you want to preserve undo changes, leaving
# them as uncommitted changes after the command runs
git rebase <branch> # Applies changes in branch you specify ontop of the
# branch you're working on, such that it's like you always had those changes in
# your branch to begin with.
git stash save "<msg>" # Stash a set of changes with a name behind it
git checkout stash@{0} -- <file> # Applies a specific filechange from your
# stash to the current branch
git checkout --. # Checks out all files from remote
git checkout <branch> -- <files> # Checks out specific files from specific branch
git add -u # Adds all already-tracked files
git branch -d <branch> # Deletes a local branch
git commit --amend # Adds onto the commit instead of making a new one
git push --force <remote-name> <branch-name> # Lets you push ammended changes
cherry-pick <hash> # Puts the spec. commit hash ontop of the branch you're in
# NOTE: add `-m 1` if you need to cherrypick a mergebranch
git log --oneline # Commit history
git reset HEAD~ # Unstages local commits
git log --author="<name>" # Search for commits by a certain person
-p # Interactive mode! Useful for git stash, merge, etc
# Permissions
chmod # How we change permissions
+x # Gives permission to run file as an executable
-R # Recursive
777 # The one you want
# Regex
\ # Use to escape so you can use metacharacters like . * etc
# Vim
:e <filename> # Creates new file buffer and opens it in current window
:vs <filename # Creates vertical split window
:sp <filename # Creates horizontal split window (omit a filename and it will open with current file
:verbose set <option> # Tells you when a vimrc option was last set
]p # Pasting in at the current indentation AFTER current line
[p # Pasting in at the current indentation BEFORE current line
P # Pastes in before cursor
"0p # Pastes from the yanked register - " is register, 0 is the
yank register
<C-t> # Jump back from a tag definition
<C-]> # Jump to the definition of a tag
<C-o> # Return to the previous spot in the code
yi<one of ),],'> # yank everything until closing character. Can do di, vi, etc
i # Means "in" (a way of referring to a chunk of something,
# just like "w" for word, etc)
a # Means "all"
gqq # format current line
help <name_of_doc># Opens documentation for a particular thing (plugin, etc)
:s/foo/bar/g # Change each 'foo' to 'bar' in the current line.
:%s/foo/bar/g # Change each 'foo' to 'bar' in all the lines.
<C-^> # Go back to previously edited buffer (switch between)
<Shift-K> # Runs `man` on whatever is under the cursor
* # Search for the word under your cursor
<C-g> # Next search occurrence
<C-t> # Previous search occurrence
# Only source vimrc when actually inside of vim!
<C-i> # Go forward in search history
<C-o> # Go backward in search history
m,M # Yank text (vim-cutlass)
<leader> hs # Stage a hunk
<leader> hu # Unstage a hunk
<C-X><C-V> # Open FZF files in split!
:Gstatus # Interactive git fugitive mode
D # Opens a diff of a file
- # Stage a file
dgu # Takes upstream version of file
dgl # Takes local version
do/dp # Used to get/revert hunks
<C-w>= # Resize all vim splits to take up an equal amt of space
# Ack
<space> a [options] {pattern} [{directories}] # Opens Ack to search
o # Goes to file in quicklist
O # Goes to file in quicklist and closes quicklist
g # Preview file
v # Open file in vertical split
# Netrw
% # New file
d # New directory
# Tmux
<C-b> # Enter tmux mode
% # Horizontal split
" # Vertical split
x # Kill a pane
& # Kill a window
] # Lets you scroll with Pg up or arrow keys or shift-K/shift-J
<Alt-arrow> # Resize panes
I # Install plugins and reload env
tmux a # attach to a session!
<C-s> # save a tmux session
<C-r> # restore a tmux session
tmux ls # list sessions
w # list all windows. type a number to select one
c # Create new window
# Python
deactivate # Leaving a venv
# Grep
grep -r "<texthere>" . # -r is recursive, <text> is text, . is current dir
grep <flags> "text" <directory> # General format for grepping
-R # recursively search directories
-i # Ignore case
-l # show file name not result
# Tail
tail -f <file> # Print the last 10 lines of a file and wait for more to come
# in. A way to watch file in realtime as it gets appended to
# Find
find <directory> -name <file pattern>
-iname # Case insensitive
-type f # files only
-type d # directories only