A shell function to easily manipulate your $PATH.
brew install boochtek/tap/pathThen add to your ~/.bashrc or ~/.zshrc:
source "$(brew --prefix)/opt/path/path.sh"Clone the repository:
git clone https://github.com/boochtek/path-manager.git ~/.path-managerAdd to your ~/.bashrc or ~/.zshrc:
source ~/.path-manager/path.shpath <command> [args]| Command | Description |
|---|---|
list, ls, show |
List all paths (numbered) |
add, a |
Add a path |
remove, rm, del |
Remove a path |
move, mv |
Move an existing path |
check, validate |
Show missing paths and duplicates |
dedup |
Remove duplicate entries |
clean |
Remove duplicates and non-existent paths |
contains, has |
Exit 0 if path exists in PATH, 1 otherwise |
help, -h, --help |
Show help |
| Option | Description |
|---|---|
--beginning, -b |
Add/move to beginning of PATH |
--end, -e |
Add/move to end of PATH (default for add) |
--before <path> |
Add/move before the specified path |
--after <path> |
Add/move after the specified path |
# List all entries
path list
# Add ~/bin to end of PATH
path add ~/bin
# Add ~/bin to beginning of PATH
path add ~/bin --beginning
path add ~/bin -b
# Add ~/bin right before /usr/bin
path add ~/bin --before /usr/bin
# Remove a path
path remove ~/bin
# Move /usr/local/bin to the beginning
path move /usr/local/bin -b
# Check for problems (missing directories, duplicates)
path check
# Clean up PATH (remove duplicates and non-existent directories)
path clean
# Check if a path exists (useful in scripts)
if path contains ~/bin; then
echo "~/bin is in PATH"
fi- Idempotent:
addsilently succeeds if path exists;removesilently succeeds if path doesn't exist - Duplicate detection: Warns when operating on paths that appear multiple times
- Path normalization: Expands
~and removes trailing slashes (preserves$VARIABLES) - Validation:
checkshows which paths don't exist on the filesystem - Cleanup:
cleanremoves both duplicates and non-existent paths in one command
- Bash 3.2+ (for built-in macOS version)
- Zsh 5.0+
A standalone script cannot modify the parent shell's environment variables (like $PATH).
The path command MUST be a shell function that gets sourced into your shell session.
MIT License - see LICENSE for details.
Use the Makefile to manage releases:
# Full release workflow (bump version, tag, push, update Homebrew formula)
make release VERSION=x.y.z
# Or run individual steps:
make bump-version VERSION=x.y.z # Commit version changes
make tag VERSION=x.y.z # Create signed git tag
make push # Push commits and tags
make update-formula VERSION=x.y.z # Update Homebrew formula with SHAThe release target automates:
- Bumping version in relevant files and committing
- Creating a signed git tag
- Pushing commits and tags to GitHub
- Downloading the release tarball and computing SHA256
- Updating the Homebrew formula with new version and SHA
Issues and pull requests welcome at github.com/boochtek/path-manager.