Skip to content

cdzombak/newt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

newt logo

newt

Manage Git worktrees with ease. newt is a simple wrapper around Git worktrees that automatically organizes them in a .newt/ directory, provides merge status tracking, and handles deletion.

Usage

newt [-b] <branch>
newt -d <worktree>
newt -l

Options

  • <branch>: Create a worktree for the specified branch in .newt/<branch>. Slashes in branch names are converted to hyphens in the directory name.
  • -b: Create a new branch and worktree together.
  • -d <worktree>: Delete the specified worktree and its branch. Asks for confirmation if the branch has not been merged.
  • -l: List all worktrees with their merge status (merged/unmerged relative to the default branch).
  • -h, --help: Print help and exit.
  • -v, --version: Print version and exit.

Examples

Create a worktree for an existing branch:

newt feature/new-api
# Creates .newt/feature-new-api/ and opens a shell there

Create a new branch and worktree:

newt -b bugfix/issue-123
# Creates new branch and .newt/bugfix-issue-123/ worktree

List all worktrees with merge status:

newt -l
# Shows worktrees with their branches and merge status

Delete a worktree and its branch:

newt -d feature-new-api
# Removes the worktree and deletes the branch
# Asks for confirmation if the branch hasn't been merged

Installation

macOS via Homebrew

brew install cdzombak/oss/newt

Shell completions for bash and zsh are installed automatically to:

  • Bash: $(brew --prefix)/etc/bash_completion.d/newt
  • Zsh: $(brew --prefix)/share/zsh/site-functions/_newt

Note: After installation, start a new shell session for completions to take effect. If completions still don't work:

# For bash, ensure bash-completion is installed and sourced
brew install bash-completion@2

# For zsh, rebuild completion cache
rm -f ~/.zcompdump && compinit

# Verify the completion files exist
ls -la $(brew --prefix)/etc/bash_completion.d/newt
ls -la $(brew --prefix)/share/zsh/site-functions/_newt

Debian via apt repository

Install my Debian repository if you haven't already:

sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://dist.cdzombak.net/deb.key | sudo gpg --dearmor -o /etc/apt/keyrings/dist-cdzombak-net.gpg
sudo chmod 0644 /etc/apt/keyrings/dist-cdzombak-net.gpg
echo -e "deb [signed-by=/etc/apt/keyrings/dist-cdzombak-net.gpg] https://dist.cdzombak.net/deb/oss any oss\n" | sudo tee -a /etc/apt/sources.list.d/dist-cdzombak-net.list > /dev/null
sudo apt-get update

Then install newt via apt-get:

sudo apt-get install newt

Shell completions for bash and zsh are installed automatically.

Manual installation from build artifacts

Pre-built binaries are downloadable from each GitHub Release. Debian packages for each release are available as well.

Build and install locally

git clone https://github.com/cdzombak/newt.git
cd newt
make build

cp out/newt-[VERSION]-all $INSTALL_DIR/newt

Shell Completions

Note: If you installed via Homebrew or the Debian package, shell completions are already installed and configured. The instructions below are only needed for manual installations.

For Homebrew installations, completions should work immediately in new shell sessions. For Debian installations, you may need to restart your shell or source the completion files:

# Bash (Debian)
source /usr/share/bash-completion/completions/newt

# Zsh (Debian)
# Ensure /usr/share/zsh/vendor-completions is in your $fpath
# and run: compinit

Manual Installation

Shell completion scripts are available in the completions/ directory.

Bash

Add to your ~/.bashrc or ~/.bash_profile:

source /path/to/newt/completions/newt.bash

Or copy the completion script to your system's bash completions directory:

# macOS (Homebrew)
cp completions/newt.bash $(brew --prefix)/etc/bash_completion.d/newt

# Linux
sudo cp completions/newt.bash /etc/bash_completion.d/newt
Zsh

Copy the completion script to a directory in your $fpath:

# Example: using ~/.zsh/completions
mkdir -p ~/.zsh/completions
cp completions/_newt ~/.zsh/completions/

Then add to your ~/.zshrc (before compinit):

fpath=(~/.zsh/completions $fpath)
autoload -Uz compinit && compinit

Or for Homebrew users:

cp completions/_newt $(brew --prefix)/share/zsh/site-functions/_newt

About

License

MIT; see LICENSE in this repository.

About

Git worktree manager

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •