1

By default, when I open the fish shell, my working directory is the home directory. Is there a way to change the default working directory on startup, without having to edit the HOME variable?

1
  • perhaps add cd /wanted/startup/directory to the end of your ~/.config/fish/config.fish Oct 29 '20 at 13:13
1

Fish does not change your CWD to $HOME when it starts. When you launch a shell from a terminal the terminal will normally have set CWD to your home directory. Your terminal may provide a way to set a different CWD when launching the shell. If it doesn't then add something like this to your ~/.config/config.fish:

if status is-login
    cd /my/preferred/starting/directory
end
2
  • So the CWD on startup is a concern for the terminal, not the shell? In that case it's good that Fish provides some way of setting the CWD even though it isn't Fish' concern. Thanks for the pragmatic solution, Glenn and Kurtis :)
    – jallersma
    Oct 30 '20 at 14:29
  • @jallersma, Yes, more or less. The CWD that fish (or any other shell) inherits is whatever the parent program decides it should be. Your question is also applicable to other shells such as bash, zsh, ksh, elvish, etc. Oct 31 '20 at 2:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.