This question has already been asked, and answered here: https://superuser.com/a/940041/293429
However, the provided solution: executing set -e PATH[<index-of-the-path-to-be-removed]
only applies to the running instance and is not valid universally.
After executing that command, if one executes echo $PATH
the previously removed paths will occur again.
One way to completely reset the path is to execute: set -U fish_user_paths
, but it is unclear to me that what it does.
The real trick would be to find out how to remove a path which has been manually added and make it available globally -- not only for the current instance?
There's two ways to do this, and which one is valid depends on how the path got into $PATH.
It is possible to add directories to $PATH via e.g. set PATH $PATH /some/dir
. At least by default, PATH is a global variable, which means it is per-session. That means to change something from $PATH, either remove it from where it is added (which is likely outside of fish since it inherits it), or put the set -e
call in your ~/.config/fish/config.fish so it will be executed on every start.
There is also $fish_user_paths, which is a universal variable (meaning it carries the same value across fish sessions and is synchronized across them). On startup and whenever fish_user_paths is modified, fish adds it to $PATH. If the offending directory is added here, execute set -e fish_user_paths[index]
once (e.g. in an interactive session).
set -e fish_user_paths
would remove the entire variable (while set -U fish_user_paths
would clear it) which would also work but would also remove all other paths
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With