A potpourri of scripts.
-
Install Xcode Command Line Tools
xcode-select --install
-
Install Homebrew and gh
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"On Apple Silicon, add Homebrew to your PATH (the installer prints these instructions):
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile eval "$(/opt/homebrew/bin/brew shellenv)"
Then install gh:
brew install gh
-
Authenticate and clone this repo
gh auth login gh repo clone lukasschwab/bin ~/bin -
Run setup script
~/bin/bin-setup.shThis installs CLI tools, GUI applications, Oh My Zsh, plugins, and symlinks dotfiles.
-
Configure shell: create
~/.zshrcwith a single line:source ~/bin/binrc
Your
.zshrccan contain additional machine-specific configuration or secrets after this line.
Dotfiles are stored in ~/bin/dotfiles/ and symlinked to their expected locations:
| Source | Symlink |
|---|---|
dotfiles/nvim/init.lua |
~/.config/nvim/init.lua |
dotfiles/zsh/lukas.zsh-theme |
~/.oh-my-zsh/custom/themes/lukas.zsh-theme |
Changes to dotfiles in this repo are automatically applied after git pull (symlinks read directly from the repo).
bashdoc prints the contents of a file until the first blank line.
This is useful for bash scripts that begin with documentation before the code,
which I aim to standardize in bin. This way, I can use bashdoc to echo help
strings without replicating them.
Usage:
bashdoc <filename>
Examples:
# Print the bashdoc for some bash utility.
bashdoc phone
# Print the bashdoc for the current script.
bashdoc "$BASH_SOURCE"
bin-setup.sh sets up a fresh macOS machine with CLI tools, GUI apps, and dotfiles.
Requires Homebrew. See README for full setup instructions.
Usage:
~/bin/bin-setup.sh
blog is a limited bash leveled-logging utility.
Usage:
blog [debug|info|warn|error] <message>
Examples:
blog debug "Here is debug context."
blog info "Here is some useful info."
blog warn "Here is a warning. Hmm..."
blog error "Ack, an error! Oh no!"
NOTE 2025-12-23: consider using https://github.com/charmbracelet/gum instead.
commits in the current repo pretty-represented in fzf, with patch previews.
Uses fzf: https://github.com/junegunn/fzf
compare two commits in the current GitHub repo in the browser.
Uses gh: https://cli.github.com/
List GitHub contributions (commits) by a given user in a given organization.
Uses:
+ gh: https://cli.github.com/
+ gum: https://github.com/charmbracelet/gum
+ jq: https://jqlang.org/
dcover checks the coverage impact of merging the current Go monorepo branch
into main.
Uses colordiff: https://formulae.brew.sh/formula/colordiff
Example:
git checkout featurebranch
dcover
Feedscan checks common feed suffixes for a webpage.
Usage:
feedscan [url]
Examples:
feedscan lukasschwab.me/blog
feedscan lukasschwab.me/blog/
feedscan http://lukasschwab.me/blog/
feedscan https://lukasschwab.me/blog/
gitclean proposes branches to delete (GitHub remote). Requires gh, gum.
Usage:
gitclean
gitdone deletes the current feature branch and returns to an updated
main branch. See: mainbranch.
fzf search on the files in `git status` output.
Uses fzf: https://github.com/junegunn/fzf
Usage, e.g.:
gsl diff
gsl add
gsl checkout - check out files
gsl -b checkout - check out branches
Use TAB to multiselect in `fzf`.
line 10 prints line 10 from stdin. For example, cat some_big_file | line 10
prints line 10 of a file.
Adapted from:
- https://evanhahn.com/scripts-i-wrote-that-i-use-all-the-time/
- https://codeberg.org/EvanHahn/dotfiles/src/commit/843b9ee13d949d346a4a73ccee2a99351aed285b/home/bin/bin/line
mainbranch returns "main" if the current git repository has a branch named
"main." Otherwise, if the repostiory has a branch named "master," mainbranch
returns "master."
margins shrinks PDF contents by 20% and splats them into a letter-size page
to add margins to them.
NOTE: this operation is not in-place; a copy of the PDF is created.
Uses pdfscale: https://github.com/tavinus/pdfScale
Usage: `margins some.pdf`
Yields some.LETTER.SCALED.pdf.
View go docs for stdlib packages or packages in the current module.
Uses fzf: https://github.com/junegunn/fzf
Usage:
moddoc
moddoc ./... Same as above.
moddoc ./... std Include stdlib.
mp3-dl downloads a YouTube video's audio as an MP3.
Uses yt-dlp: https://github.com/yt-dlp/yt-dlp
Use with id3ed to edit MP3 metadata: https://github.com/lukasschwab/id3ed
Usage:
mp3-dl https://www.youtube.com/watch\?v\=MH_D26i2NyE
nato bar returns Bravo Alfa Romeo.
Adapted from:
- https://evanhahn.com/scripts-i-wrote-that-i-use-all-the-time/
- https://codeberg.org/EvanHahn/dotfiles/src/commit/843b9ee13d949d346a4a73ccee2a99351aed285b/home/bin/bin/nato
nw opens a new Ghostty terminal window with a selected theme.
Uses fzf to select a theme with a color palette preview.
The new window launches detached from the current terminal.
Usage:
nw # Interactive theme picker
nw --light # Pick from light themes only
nw --dark # Pick from dark themes only
nw <theme> # Launch directly with specified theme
nw --preview <theme> # Show theme preview (used internally by fzf)
nw --working-directory <dir> # Open in specified directory
Requires: ghostty, fzf
path sorts and prints all components of the current path. Could just as well
be an alias instead.
pdfcat uses PhantomJS to retrieve websites as PDFs, then catenates the PDFs
into a single PDF with Ghostscript. Spooky!
Usage: pdfcat https://scrty.io/start-here \
https://medium.com/starting-up-security/starting-up-security-87839ab21bae \
... any number of URLs.
Uses Twilio to notify me of a long task completing.
e.g.:
$ gcloud app deploy; phone
Setup:
Set up Twilio API/CLI: https://www.twilio.com/docs/twilio-cli/quickstart
Add two variables to .zshrc:
TWILIO_NUMBER="+1234567890" # A number from which Twilio can send.
PERSONAL_NUMBER="+0987654321" # The number that will be notified.
pick a random file in in the current working directory (recursive).
semvercompare compares two semantic versions with the same number of
components.
Usage: semvercompare <v0> <v1>
semvercompare 1.2.10 1.3.10
Output:
1 - when v0 is later than v1
0 - when v0 and v1 are the same
-1 - when v0 is earlier than v1
straightquote converts "smart quotes" to "straight quotes" (sometimes called
"dumb quotes").
Adapted from:
- https://evanhahn.com/scripts-i-wrote-that-i-use-all-the-time/
- https://codeberg.org/EvanHahn/dotfiles/src/commit/843b9ee13d949d346a4a73ccee2a99351aed285b/home/bin/bin/straightquote
tikz2svg converts a tikz document to SVG, via PDF.
Uses:
+ xelatex (though it should be easy to sub in pdflatex) and
+ pdf2svg: https://formulae.brew.sh/formula/pdf2svg
Usage: tikz2svg [someTikzFile.tex]
Example input: https://gist.github.com/lukasschwab/6a3e2cdd78075e8923a9057f7609a898
See also: https://pandoc.org/lua-filters.html#building-images-with-tikz
t -e
t -u
t -o pipefail
todo lists incomplete tasks in/below your pwd.
topdf is a wrapper for a standard Pandoc configuration for rendering a
simple Markdown file as a PDF. Requires pandoc, xelatex.
Usage:
pandoc <filename.md>
# You can pass additional pandoc arguments.
pandoc <filename.md> --toc
unstash from `git stash list`: fzf with preview.
Uses fzf: https://github.com/junegunn/fzf
Usage:
unstash
wt creates a new git worktree and opens a terminal window in it.
Uses gum for interactive input and nw to open the new terminal.
Usage:
wt # Interactive worktree creation
Requires: git, gum, fzf, nw