In my previous post about just, I showed how a justfile in each project keeps all commands in one place. But some commands are not tied to any project. Updating dotfiles, cleaning up Docker, checking disk usage. You want those available everywhere.
The solution is a global justfile.
This post is part of my terminal workflow series.
How it works
Create a justfile in your config folder:
mkdir -p ~/.config/just
touch ~/.config/just/justfile
Then add an alias to your .zshrc:
alias jg="just --global-justfile --choose"
The --global-justfile flag (available since v1.14) automatically looks for ~/.config/just/justfile. Adding --choose opens a fuzzy finder every time, so you pick a recipe instead of remembering its name.
Now jg opens a fuzzy finder with all your global recipes, no matter where you are. Your per-project just keeps working as before.
Example global justfile
# Show available commands
default:
@just --list
# ---------- System ----------
# Update Homebrew and all packages
brew-update:
brew update && brew upgrade && brew cleanup
# Show disk usage for home directory
disk:
du -sh ~/* 2>/dev/null | sort -rh | head -20
# Clean up Docker (containers, images, volumes)
docker-clean:
docker system prune -af --volumes
# ---------- Dotfiles ----------
# Pull latest dotfiles
dotfiles-pull:
cd ~/dotfiles && git pull
# Push dotfiles changes
dotfiles-push:
cd ~/dotfiles && git add -A && git commit -m "update" && git push
# ---------- SSH ----------
# List all SSH keys
ssh-keys:
ls -la ~/.ssh/*.pub
# Copy SSH public key to clipboard
ssh-copy:
pbcopy < ~/.ssh/id_ed25519.pub && echo "Public key copied to clipboard"
# ---------- Utilities ----------
# Show current public IP
my-ip:
curl -s ifconfig.me && echo ""
# Kill process on a specific port
kill-port port:
lsof -ti :{{port}} | xargs kill -9 2>/dev/null || echo "No process on port {{port}}"
Usage
# Open fuzzy finder with all global recipes
jg
# Run a specific recipe directly
just --global-justfile brew-update
That is it. One file for all your machine-wide commands, one alias to run them from anywhere.
Spot something wrong?
Found a typo, a broken link, or something that could be better? I would love to hear from you. Drop me a message and I will fix it.
Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.