Make Fish start me in a directory other than HOME

半世苍凉 提交于 2019-12-06 11:20:29

I assume you're referring to this comment in the question you liked to:

No, don't do it! If you add a cd to your config.fish, it will work for everyday use, but fish will also run the cd before you run any Fish shell script.

And that is true as far as it goes. The config.fish script is read by every fish process regardless of whether or not it is interactive. The way to deal with that is to only do the cd if the shell is interactive:

if status is-interactive
    cd /vagrant
end

Note that you may need to use status -i if you're running an old version.

Also, in case it isn't obvious, this doesn't actually change $HOME and thus does not change where fish looks for your personal autoloaded functions or where it stores its command history. So if you want to "use ~vagrant as the place where VM-specific configuration gets dumped" you need to actually change your home directory. Alternatively, in addition to executing the cd command also set HOME.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!