Richard Bucker

fishshell, boot2docker and my config

Posted at — Jan 10, 2015

I like fishshell for a number of reasons with my favorite being the CLI. While it does not support ^R, out of the box, in order to search the command history it feels a lot more natural. Just start retyping the desired command and it will find and highlight the previous versions which you can scroll and select. Of course it has the weakness that if the first few letters of the command are not the same as the next command then there is some CLI navigation gymnastics… but at least the normal operation is the normal operation.I suppose I have gotten used to the fact that the .bashrc and .profile files are in the $HOME folder because when fish decided to put it’s config file here: $HOME/.config/fish/ I could never remember the exact folder and in some cases I could not be bothered to search the docs. This is part of my green folder initiative.My fish/ looks like this:set -x fish_user_paths $HOME/binset -x GOPATH $HOMEgo env|grep GOROOT | sed -e “s/(.)=(.)/set -x \1 \2/” |sourceThe first line adds my bin folder to the PATH environment variable without having to do the work myself. If memory serves the function will check for dupes. This may or may not be a bad thing if order is important… and it should never be.The second line is obvious. It’s just creating the default GOPATH. This is just temporary because there is an idiomatic way to manage the GO environment. I think the GO authors intended for users to set the variable manually or as part of a make/build so that the environment was semi sandboxed and idempotent.Then the last line. I’m attempting to extract the GOROOT from the current GO cmd and then set the environment in the fish-way. What’s interesting is that GO is supposed to figure out it’s own GOROOT but it’s not very good at it in fish.  I suppose I could have hard coded it, however, I have been known to swap between the homebrew installation of GO and the source or binary directly from GO. I like homebrew because it’s fast and easy to install, uninstall, update and upgrade. Not forget that they offer some feature flags for cross platform and others. I hope they stay current.Finally, absent from the config file is the boot2docker and docker commands. I’m on the fence with this because setting the docker/boot2docker environment is easy but it means that boot2docker has to be running in the VM and I’d rather do that selectively. I tend to move around between local and remote development. So making it optional is better.Note that the output from the boot2docker shellinit command is compatible with fish and while you might use:$(boot2docker shellinit)in bash; in fish you’ll use:boot2docker shellinit | sourceThe changes to the environment are exactly the same.