Fuck it, .zshrc
it is.
Image transcription:
- Top text: I STILL DON’T KNOW WHAT SHOULD GO IN .*RC VERSUS .*PROFILE
- Bottom text: AND AT THIS POINT I’M AFRAID TO ASK
I found this diagram on SO at one point but I can’t find the post and it is the best explanation I have found for how all of the files work for bash and zsh, each color is an individual path of execution (eg, follow the red line).
Bottom line though, it only really matters if you are overriding something that is already defined, for example I tell my users to use zshrc and I provide defaults and common things in zprofile because zshrc is executed last when they login.
I feel like I couldn’t make this more confusing if I tried. What is doing on with the golden arrows around
/etc/profile
??Agreed! It’s cathartic to see it laid out so terrifying. Now I feel less bad for never understanding it.
Afaik the difference is whether a session is interactive or not, and non-interactive ones don’t source the rc
But what would I want in a login shell that I don’t also want in a non login shell?
Presumably just to get rid of unnecessary stuff that would slow down the start of all bash instances. Also aliases that could fuck with scripts
Switching to Fish was the best decision I ever made in my terminal. Besides using tmux.
Isn’t the POSIX incompatibility a major roadblock when scripting?
Not really, you can make .fish scripts or call “bash script.sh” when it’s more appropriate to be posix compliant
Yeah. Fish just simplifies life everywhere. No longer do I need to care about those silly files or other configurations for basic stuff like search history.
Best decision ever.
The only thing I miss in fish is
$?
I know
$status
exists but my fingers don’t.
Alright stranger, let’s hear it. What is it about Fish that you love so much?
I’ve been generally happy with bash or zsh, pretty much whatever is installed by default (and I honestly don’t know the difference between the two I just mentioned 😬).
Once upon a time I was the person that was constantly messing with my shell. I would performance tune it, try out new plugins weekly, change my config often. It honestly became a huge waste of time. Since switching to fish I literally haven’t spent any time configuring it at all, besides adding in the fzf plugin and the fzf-marks plugin. It just works. And it has all of the same features that everyone adds to zsh with plugins straight out of the box.
If you’re happy with the default in bash or zsh then you will be even more happy with the default in fish, as it’s just much much more user friendly (which is why so many people add so many plugins to bash and zsh: to make it more user friendly). You can even configure it (even the colors) with a web interface! No mucking about in text files if you don’t want to.
Zsh has more features and customization options than bash. Fish has a ton of convenience features at the cost of POSIX compatibility (which many view as a good thing)
It’s all about context. If you write a convenience function and put it in zshrc, scripts you run from the cli will not have access to the function as defined in zshrc. Same with aliases added by zsh plugins etc.
If you need “the thing” on the command line, zshrc. If you also need it in scripts you run from the cli, toss it in the profile file.
ETA: I personally keep the functions I want to access from scripts in .zshenv as I recall reading that this file is ALWAYS sourced.