Skip to content
rhefnerPublic

About

Git worktree setup, switching, organization, and branch cleanup CLI & Bubble Tea TUI

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

workon

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.

Features

  • Fast worktree creation & switching: workon <slug> creates or switches into a sibling worktree for <prefix>/<slug>
  • Interactive Bubble Tea TUI: run workon with no arguments for worktree creation, switching, base-branch selection, cleanup, and repo setup
  • Safe branch cleanup: workon branches-no-upstream and workon remove-branches-no-upstream inspect and prune branches whose remote upstream is gone
  • Repo organization: workon setup and workon organize standardize repositories into dedicated worktree directories
  • Per-user config: stored in $XDG_CONFIG_HOME/workon/config.json (default ~/.config/workon/config.json)

Install & Run

Nix (Flakes)

Run directly without installing:

nix run github:rhefner/workon

Install into your user profile:

nix profile install github:rhefner/workon

Add 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

go install github.com/rhefner/workon/cmd/workon@latest

Shell Wrapper (for automatic cd)

Because 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"
}

Common Commands

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 & defaults

License

MIT

About

Git worktree setup, switching, organization, and branch cleanup CLI & Bubble Tea TUI

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages