要在 fish 中的 $PATH 添加一些内容,我使用
fish_add_path -a ~/foo/bar
然后鱼添加~/foo/bar
到我的~/.config/fish/fish_variables
:
SETUVAR fish_user_paths:/Users/john/foo/bar
/Users/john/foo/bar
那么,要从$PATH 中删除,我有两个选择,这样说正确吗:
编辑
fish_variables
文件使用以下函数:
// 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
问题的第二部分是:如何正确使用该函数?我将其保存为remove_from_path.fish
,并执行为remove_from_path.fish "/Users/john/foo/bar"
,但它似乎没有/Users/john/foo/bar
从 $PATH 中删除。我做错了什么?