Shell Path Manager is a simple and intuitive tool for managing shell path.
I want to develop this tool because I got the problem about managing the PATH on my mac each time after I install something, when I install Go, when I install yarn etc. But I didn’t find any handy tools to satisfy my needs.
This tool is just for simplifying some staff like export $PATH:some-new-path
or vi ~/.zshrc
, adding something and source ~/.zshrc
or restart the terminal.
Some binary tools may auto do this for you but some others don’t. I think they can do this but they don’t have to, so programmers still have to manager shell environment themselves in the end.
But I think it’s a burden for me to do these things each time when I install something, especially as a frontend developer, I just want to install some CLI tools which just used as a binary to create something.
So, I made it.
It makes me easier for some misc staff and I hope it will decrease the complexity for new frontend developers or amateurs.
If it helps you too or any questions, just contact me and pull requests are welcome.
Installation
curl -fsSL https://raw.githubusercontent.com/barnett617/shell-path-manager/main/tools/install.sh | bash
Above shell script does these things:
- create .spm under user home
- create .spm/bin/spm and append ~/.spm/bin to PATH in order to invoke spm anywhere in shell
- create .spm/path
Usage & How it works
spm list
This command just does one thing cat ~/.spm/path
spm add go=/Users/mac/go/bin
This command appends the input to ~/.spm/path
spm remove go
This will do following thing:
- readline from ~/.spm/path
- find the match key of the name to remove
- delete the matched line
- rewrite to ~/.spm/path
spm uninstall
This will not change your exist path but only remove all things about spm, which is remove rm -rf ~/.spm
Why I made it
See Learning Shell by Making a tool for myself
Some discussion about this pain
- https://stackoverflow.com/questions/370047/what-is-the-most-elegant-way-to-remove-a-path-from-the-path-variable-in-bash
- https://stackoverflow.com/questions/273909/how-do-i-manipulate-path-elements-in-shell-scripts
Inspiration
There are some projects which I found when I want to decently manager my path before I made this.
Some more things
AFAK Windows users can edit their paths via a visual window at least, so I don’t have any plans to support this tool for Windows.
You may not have Node or proper version of Python on your computer, but you definitely have a shell, no matter Bash or Zsh, so this tool will suit for most Mac users.