path-ethic
is a native Zsh
plugin that provides CLI for PATH
manipulation, preset management and automatic loading. It does not touch your existing .zshrc
, .zprofile
or any other shell environment configuration, but adds on top of your existing environment.
- quick and easy CLI based
PATH
management - named
PATH
presets - automatic preset loading
- scripting friendly
- designed to work with Zsh only
- the default preset cannot completely override the shell
PATH
If you are looking for a more comprehensive and advanced shell environment configuration management tool, or something that supports more shells, check out direnv.
peth [show]
- displays the current value of PATH
and the values of any set prefix and suffix.
peth list
- similar to show
but lists elements in separate lines.
peth push <path>
- adds a new element at the beginning of the PATH
and re-exports.
peth append <path>
- adds a new element at the end of the PATH
and re-exports.
peth flip
- flips the prefix and suffix to reverse their priority. This is a very handy feature if often need to switch between different verisons of the same software.
peth rm <path>
- removes a path element from the PATH
and re-exports.
peth reset
- removes all prefixes and suffixes and re-exports the original PATH
.
peth save [name]
- saves the current session PATH
settings as a preset for later recall. If the optional name argument is provided, settings are saved as a named preset, otherwise
they are saved to the default preset. The default preset is special in the fact that it does not include changes made to the original PATH
during the session. Instead it only saves
the prefix and suffix. This makes it possible to always go back to your current .zshrc
or .zprofile
set PATH
settings and edit from there.
- Data is saved to
~/.path-ethic
- User home paths are substituted with
$HOME
for better portability
peth load [name]
- loads a previously saved preset into the current session. If the optional name argument is provided, attempts to load a named preset, otherwise loads the default
preset.
peth listp
- lists all saved presets with a visual indication regarding which one is currently loaded.
peth rmp <name>
- removes a previously saved named preset.
peth update
- if cloned from a remote git repository, prompts to pull the latest changes from that remote.
peth help
- displays help.
When you change directory the plugin looks for a file named .pethrc
in the target directory. If one is found, it tries to read a preset name from it and load it into the current session. This is helpful if you need different sets of tools or verisons for different projects. To take adventage of this feature, first save a named preset and then just create a .pethrc
with its name in your project directory.
The plugin comes bundled with completion functions that are automatically registered to be loaded if Zsh completion system is enabled.
If completion doesn't work for the peth
command, consider adding the following to .zshrc
.
# enable autocomplete functions
autoload -U compinit
compinit
- Clone this repository to a directory of your choice
cd /your-dir
git clone git@github.com:sha1n/path-ethics.git
- Enable the plugin by sourcing it's main script in
~/.zshrc
.
source /your-dir/path-ethic/path-ethic.plugin.zsh
- Clone this repository to
$ZSH_CUSTOM/plugins/path-ethic
mkdir -p "$ZSH_CUSTOM/plugins" && git clone git@github.com:sha1n/path-ethics.git "$ZSH_CUSTOM/plugins/path-ethic"
- Enable the plugin by adding
path-ethic
to the plugin listplugins=()
in~/.zshrc
.
plugins=(
path-ethic # <-- add this
)
- Reverse the installation steps.
- You may want to delete the directory
~/.path-ethic
. This is where committedPATH
elements and presets are saved.
In order to make committed changes more portable, right before changes are saved all user home paths are replaced with $HOME
.
Therefore, when you migrate settings to a new computer or user on the same computer, you can simply install the plugin, copy ~/.path-ethic
to your new home directory and you should be good to go.