Dev Notes

ZSH

Files

What How
Open a finder window open .
Find a file find ~ -name "*.zim" 2>/dev/null
Find an executable (in path) command -v executable-to-find
E.g., find the Rust compiler (if it exists) command -v rustc
Get info about a file file foo
Chain commands (only run second if first succeeds git fetch && git status

Environment

What How
Show current environment variables printenv
Show current $PATH. Note: $path is an array version of $PATH, and print -l puts array elements on new lines print -l $path
A more generic version. Note: tr “translates” colon into newlines. echo $PATH | tr ':' '\n'
Show mounted drives lsblk
Get network info ip a
ip route

chmod

What How
Make a file executable: chmod +x file

Pure BASH Bible

The goal of this book is to document commonly-known and lesser-known methods of doing various tasks using only built-in bash features. Using the snippets from this bible can help remove unneeded dependencies from scripts and in most cases make them faster.

Eleventy

What How
Build site npx @11ty/eleventy
Build site and start local server npx @11ty/eleventy --serve

GIT

Create a local repo

What How
Create a repo git init
Create a .gitignore cat > .gitignore <<EOF
# macOS
.DS_Store
EOF
Stage and commit git add .

git commit -m "Initial project"

Create repo on GitHub

What How
Add the GitHub remote git remote add origin https://github.com/username/project.git
Push commits git branch -M main #rename default branch to 'main'

git push -u origin main #push and set upstream

Create a branch

What How
Create a branch git checkout -b branch-name

git push -u origin branch-name
Replace main with branch git push origin branch-name:main --force

git checkout main

git fetch --all

git reset --hard origin/main

Abandon a branch

What How
Switch back to main git checkout main
Replace main with branch git push origin branch-name:main --force

git checkout main

git fetch --all

git reset --hard origin/main
Remove local branch git branch -d old-branch
Force delete the branch (if sure you don't want anything in it) git branch -D unwanted-branch
Remove remote branch git push origin --delete old-branch

Archive

What How
Zip (secure) 7z a -tzip -mem=AES256 -p archive.zip /path/to/files_or_folder
Zip (split into 2GB volumes) 7z a -tzip -mem=AES256 -p -bb3 archive.zip /path/to/files_or_folder
Unzip 7z x archive.7z