add a folder to the path
Let the shell find programs in a folder, for good, and reload the settings without logging out.
Steps
-
echo "$PATH" | tr : '\n'the folders searched now, one a line
-
export PATH="$HOME/bin:$PATH"add ~/bin for this shell
-
echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrcadd it for good (bash)
-
source ~/.bashrcload the change now, without logging out
-
fish_add_path ~/binfish: adds it for good
Notes
- zsh: ~/.zshrc. Login shells on macOS read ~/.zprofile or ~/.bash_profile.
Commands used
exportsource
Each has a page in lore: lore export opens it.
Related recipes
- add to the end of a fileAdd lines to a file without replacing it, also to a file only root can write.
- argument list too long"Argument list too long" from rm, cp or mv: too many files for one command line. Hand them over in batches.
- ask for input in a scriptAsk yes or no, read a password without showing it, or wait for an answer with a time limit.
- check if a file or folder existsTest in a script whether a path exists, is a file, a folder, empty or runnable.