A Go CLI and Bubble Tea TUI for managing Git worktrees cleanly: spin up sibling worktrees per branch/ticket, switch directories seamlessly via a shell wrapper, organize repos into a repo/<branch> layout, and prune merged/stale branches whose upstreams are gone.
Extracted from my private Nix dotfiles, where it has been in daily use, into a standalone public repository.
- Fast worktree creation & switching:
workon <slug>creates or switches into a sibling worktree for<prefix>/<slug> - Interactive Bubble Tea TUI: run
workonwith no arguments for worktree creation, switching, base-branch selection, cleanup, and repo setup - Safe branch cleanup:
workon branches-no-upstreamandworkon remove-branches-no-upstreaminspect and prune branches whose remote upstream is gone - Repo organization:
workon setupandworkon organizestandardize repositories into dedicated worktree directories - Per-user config: stored in
$XDG_CONFIG_HOME/workon/config.json(default~/.config/workon/config.json)
Run directly without installing:
nix run github:rhefner/workonInstall into your user profile:
nix profile install github:rhefner/workonAdd to your NixOS / nix-darwin / Home Manager flake.nix:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
workon.url = "github:rhefner/workon";
};
outputs = { self, nixpkgs, workon, ... }: {
# In your home-manager or system packages list:
# home.packages = [ workon.packages.${pkgs.system}.default ];
# Or apply the overlay:
# nixpkgs.overlays = [ workon.overlays.default ];
};
}go install github.com/rhefner/workon/cmd/workon@latestBecause child processes cannot change the parent shell's working directory directly, workon emits a structured directory change protocol when wrapped in a shell function:
# Bash / Zsh
workon() {
local out status
out="$(command workon --json "$@")"
status=$?
if [ "$status" -eq 10 ]; then
local target
target="$(printf '%s' "$out" | jq -r '.cwd')"
[ -n "$target" ] && cd "$target"
return 0
fi
return "$status"
}workon # open interactive TUI
workon my-feature # create/switch worktree for <prefix>/my-feature
workon branches-no-upstream # list branches whose upstream was deleted
workon remove-branches-no-upstream # dry-run cleanup (add --confirm to execute)
workon setup # initialize or clone a worktree-managed repo
workon organize # reorganize worktrees into canonical layout
workon config # inspect or update branch prefix & defaultsMIT