Skip to content

Instantly share code, notes, and snippets.

@nicktehrany
Last active December 26, 2021 14:03
Show Gist options
  • Save nicktehrany/7126ec0ad18f0af050e15596371ceea5 to your computer and use it in GitHub Desktop.
Save nicktehrany/7126ec0ad18f0af050e15596371ceea5 to your computer and use it in GitHub Desktop.
Useful Commands

Usefule commands

gist with all useful commands that I use or need and tend to forget since it's just too many, a lot of these are custom key mappings so they might not work by default.

bspwm

Super a # Resize mode, then with hjkl
Super ctrl {hjkl} # preselect area
  Super y # send current window to preselected area
  Super ctrl shift space # cancel preselection on focused desktop
Super shift a # rotate counter clockwise
Super shift d # rotate clockwise

Vim

some vim commands (some are specific to my plugins and keymaps!)

Ctrl + c # compile latex file
Ctrl + l # clear output log from latex compile

Ctrl + b # open NerdTree
Ctrl + r # refresh NerdTree

:sp # split horizontally
:vsp # split vertically

# Navigation
gg # jump to top of file
G # jump to end of file
ZZ # save and quit
ZQ # quit
\tab # switch to next tab in buffer
\ Shift tab # swithc to previous tab in buffer
/ # search use N and Shift + N to navigate them
w # goto next word
b # goto previous word
{ # goto previous paragraph
} # goto next paragraph
0 # goto beginning of line
$ # goto end of line
Ctrl + ] # goto function def (requires ctags and other plugins installed)
Ctrl + ^ # goto previous location
Ctrl + o # cycle through previous locations
Ctrl + i # cycle through next locations
u # or U inside Nerdtree to up a dir

# Editing
Ctrl + w # delete previous word in insert mode
a # insert mode after character
o # insert mode after line
dd # delete Line
D # delete part of line after cursor
cw # delete next word and enter insert mode
di( # delete everything inside (), leave the parenthesis
da( # delete everything inside (), including the parenthesis
gq$ # wrap words until end of line (or gq0 for until beginning of line)

:m +1 # move line 1 down (- for up and line numbers) if no plus line number is absolute

# Combos
# Comment/Uncomment blocks
Ctrl v # visual block mode
j # for all lines or just 9j for example
Shift i # Insert at the beginning of block (for uncomment just press x here and skip next step)
% # or whatever comment char there is

# Wrap text, nice for md or tex files
V # visual line mode
10j # or any to select the lines
gw # wrap at 120 chars

# Buffers
:e <filename> # Open filename in new buffer
:ls # List buffers
:b <Index> # Switch to buffer with index (from ls)
:bd <Index> # Close and remove buffer with index

Zathura

K # Zoom in
J # Zoom out
t # goto top
u # go half page up
d # go half page down
i # invert colors
D # change page mode (dual/single)

Gnome PopOS! Shell Window Tiling

Super + / # go through applications
Super + y # Tile windows
Super + o # change orientation

Super + enter # adjustment mode
  arrow # move window
  Ctrl + arrow # swap windows
  Shift + arrow # resize
  Super + Shift + down # move window down one workspace
  Super + Shift + right # move window to right monitor

Super + s # stacking mode
Super + g # floating mode

tmux

# Prefix is Ctrl a for me
prefix [ # enter visual mode (leave it with q)
prefix % # horiontal split
prefix " # vertical split
prefix c # new window
prefix & # kill window
prefix , # rename window

Key Remapping

xev # gui to find out the keycode of a key
xmodmap -e 'keycode 110=Delete' # remaps the home key to delete

Vifm

zo # show hidden files
zm # hide hidden files
w # preview
cw # change name (with extensions)
cW # change name (without extensions)
Tab # switch pane
Shift Tab # switch to preview pane

Misc

grep -rHn 'word' *.md # grep all md files for the word

pandoc file.md -o file.pdf # markdown to pdf conversion

pdfunite <src files> <dest file> # concatenate pdfs into one

Docker

# delete all exited containers
docker ps -a | grep Exit | cut -d ' ' -f 1 | xargs docker

# delete all untagged images
docker rmi -f $(docker images | grep "<none>" | awk "{print \$3}")

fzf

ctrl r # reverse search history
ctrl t # fuzzy find current dir
alt c # cd into dir with fzf

git tracking a remote master branch

mkdir some-repo
cd some-repo
git init
git add remote add orogin <LINK TO YOUR REPO>
git add remote add upstream <LINK TO REPO TO TRACK>
git remote -v # Check if all is good
git pull upstream master
git push origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment