Last Updated: July 24, 2017
·
45.06K
· blackdragn

Manipulating PATH variable in fish-shell

Add path temporarily:

$ set -gx PATH $PATH <path>

Add path permanently:

$ touch ~/.config/fish/config.fish
$ echo "set -gx PATH \$PATH <path>" >> ~/.config/fish/config.fish

Long story: fish-shell is the best shell ever. If you haven't tried it before, do it now: http://fishshell.com/.
Adding something to PATH variable is a common task, it helps you to use short command names in the shell instead of full paths to executables.

The first code snippet uses fish's builtin command set to add the <path> (replace it with a path to the executable) to the end of PATH array. Flags -g and -x mean, 'global' and 'export' (you can read about it in "man set"). This setting will be lost after you quit the current shell session, but it is good for testing.

The second snippet ensures that you have the fish's config file, and adds the first command to the end of it. After that, the variable will be set every time you start the shell.

2 Responses
Add your response

or set --universal fish_user_paths $fish_user_paths <path>

over 1 year ago ·

how about for gems?

over 1 year ago ·