Friedrich Ewald My Personal Website

Cheatsheets

This page contains several cheatsheets for applications that I use frequently.

ASDF

Install asdf from via brew with brew install asdf.

asdf list  # List all installed applications and marks their defaults with a star
asdf local nodejs 23.6.0  # Set the local version of `nodejs` to `23.6.0`

curl

curl -k https://example.com  # -k allows self-signed (insecure certificates)

Disk

Several commands to handle disk space related questions

df -h                     # Shows all disks, their mountpoints and how much space is available
du -sh path               # Calculate size of a particular folder, including subfolders
du -h --max-depth=1 path  # Show the size of all subfolders under path with a maximum defined depth

Git

git switch <branch>      # Switch to a remote branch locally and set up tracking the remote branch
git commit --allow-empty # Allow empty commits (useful for adding just a message)

git config user.email "[email protected]"  # Set email for the current repository

Grep

grep "pattern" file.txt  # Search for a pattern in a file

jq

jq '.' file.json        # Basic usage, load file.json and select everything
jq '.key' file.json     # Select everything under "key"
jq '."key-with-dashes"' # Select from special key-with-dashes

Linux

sudo -u user command  # Run command as specified user
Ctrl+Z # Move current command to the background, keeps running
fg     # Move background command to the foreground again

bc -l  # Run interactive a basic calculator with 20 digit precision
find . -name "file.py"  # Search for file.py in current folder and all subfolders

MySQL

-- Log all queries
SET GLOBAL log_output = 'TABLE';
SET GLOBAL general_log = 'ON';
SELECT command_type, argument FROM mysql.general_log;

SSH

ssh-add -l            # List all identities added to the SSH agent
ssh-add -D            # Delete all identities
ssh-add path/to/file  # Add private key to ssh-agent

ViM

Packages & Plugins

File Management

:e .   # Open a file explorer in the current working directory
:tabe  # Open file in new tab
:tabn  # Go to next tab
:tabp  # Go to previous tab
:w     # Write current file
:q     # Quit ViM
:q!    # Force Quit ViM

Cursor navigation

:/<term>  # Search for term
n         # Next search hit
p         # Previous search hit

w         # Next word
b         # Previous word

Ctrl+f    # Scroll forward to next page
Ctrl+d    # Scroll down half a screen
Ctrl+b    # Scroll backward to previous page
Ctrl+u    # Scroll up half a screen

Window Management

:sp        # Open new horizontal split with current file
:vs        # Open new vertical split with current file
:term      # Alias of terminal, close with Ctrl+D
:terminal  # Open a new terminal window, close with Ctrl+z

Ctrl+w h   # Switch to left window
Ctrl+w l   # Switch to right window
Ctrl+z     # Bring window to the background (open a shell), return with "fg"

Text Manipulation

i      # Switch to insert mode at the current cursor
A      # Append to current line at the end
o      # Insert line below
O      # Insert line above
u      # Undo latest change
Ctrl-r # Redo latest change
dw     # Delete word
d$     # Delete from cursor position to end of line

~    # Switch between upper and lower case
guu  # Switch current line to lower case
gUU  # Switch current line to upper case
Resize Operations

Ctrl+w -   # Shrink current window horizontally
Ctrl+w +   # Expand current window horizontally
Ctrl+w >   # Expand current window to the right (Remmeber to press the Shift key)
Ctrl+w <   # Shrink current window to the left (Remember to press the Shift key)