Useful tips for working with the fish shell. Fish manages user-defined paths through a universal variable called fish_user_paths.
Use fish_add_path to add a directory. It updates fish_user_paths persistently and avoids duplicates:
fish_add_path /path/to/add
Use -v to print the underlying set command that is executed, and verify the result:
fish_add_path -v /path/to/add
echo $fish_user_paths | tr " " "\n" | nl
echo $fish_user_paths | tr " " "\n" | nl
Use contains -i to look up the index of the entry you want to remove and erase it in one step:
set --erase --universal fish_user_paths[(contains -i /path/to/remove $fish_user_paths)]
This avoids the two-step process of listing entries and manually entering the index number.
fish_user_paths is a universal variable, meaning changes persist across all fish sessions automatically.