web analytics

Emacs and a non-POSIX standard shell

April 12, 2015

I like fish. Both the animal (great source of protein) and the shell. In fact whenever I setup a new computer, which happens less often now, the first thing I install and configure is the fish shell. No, bash is not my standard shell, fish is my standard shell.

What I like about fish, it really knows how to shine (read it at the tune of What I Like About You). Kidding aside, it has autosuggestions that are displayed inline, Emacs keybindings, I can understand its script system, which is more than I can say about bash. Don’t get me wrong, I can bash script my way around some simple hacks, but I don’t have to like it ok? And then I can pimp my term with oh-my-fish.

For all its goodness, it can cause you some problems to love fish as much as I do. For starters, setting it as your default shell is not as straightforward in OS X as it could be. I understand it is not something that regular users would do, but still. You have to go into System Preferences and do an incantation of holding the control key while clicking on your username. An advanced options menu will popup and you have to click on it while wording the spell Expecto Pescado (or so I’m told) to get to the panel where you change this setting. Once you do that you’re golden, until you load up Emacs and try to use an external command.

Emacs relies on external programs for things such as spelling, source control, linting, etc. When you start up Emacs in graphical mode, it gets some environment variables. Normally if you can execute a program in your shell, you would expect Emacs to be able to do the same, don’t you? Well, only if both have access to the same set of environment variables such as the all mighty path. When you have fish as your default shell this won’t be the case, and then Emacs will complain (and rightfully so) that it can’t find a program, even when you are pretty sure that the program is right there!.

Enter exex-path-from-shell
Of course there’s a package for that. It’s called exec-path-from-shell and what it does is… get the path, from your shell. Voila! Emacs will happily chug along even good old bash is no longer your default shell.

On a sidenote, if you decide to try fish for yourself, be aware that it is a different shell. Bash is so ubiquitous that most of the scripts and snippets found in tutorials or articles will be written for bash. Keep that in mind!