To add something to $PATH in fish, I use
fish_add_path -a ~/foo/bar
Then fish adds ~/foo/bar to my ~/.config/fish/fish_variables:
SETUVAR fish_user_paths:/Users/john/foo/bar
Then, is it correct to say that to remove /Users/john/foo/bar from $PATH, I have two options:
to edit the
fish_variablesfileto use the following function:
// https://github.com/fish-shell/fish-shell/issues/8604#issuecomment-1169638533 function remove_path if set -l index (contains -i "$argv" $fish_user_paths) set -e fish_user_paths[$index] echo "Removed $argv from the path" end end
And the second part of the question: How to properly use that function? I saved it as remove_from_path.fish, executed as remove_from_path.fish "/Users/john/foo/bar", but it doesn't seem to remove /Users/john/foo/bar from $PATH. What I'm doing wrong?