Over time, I’ve built up a collection of tools which make my life easier in the shell. I’m constantly exploring and trying new tools, most of which get ditched fairly rapidly, but there are some which have survived the perpetual cull.
I’d like to share a few of them with you. You won’t find all of these useful in the same way that I do, but there might be some which are new to you and have some value.
Many of the tools I’ll mention are shell-agnostic, meaning that they don’t care which shell you’re using. The shell functions later in this piece are intended for https://github.com/fish-shell/fish-shell and in most cases will not work directly in bash
or zsh
.
I am a big proponent of fish
. It’s not nothing that the syntax differs from what you might be more familiar with, but I like the changes.
One example is the following -
bash
/ zsh
while true
do
echo "hello"
done
if true
then
echo "hello"
fi
export FOO=BAR
export PATH=$PATH:/path/to/bin
fish
while true
echo "hello" # note lack of 'do/done'
end
if true
echo "hello" # note lack of 'do/done'
end
set -Ux FOO BAR # 'universal', persists forever
# saved in ~/.config/fish/fish_variables
# editing this file by hand is allowed
# changes are reflected immediately
set -gx FOO BAR # 'global', persists only in this shell
# session
set -lx FOO BAR # 'local', persists only in this shell
# session, with only local scope
# remove -x from any of the above `set` commands to not export an env
# variable, only make the variable available to fish
fish_add_path /path/to/bin # edits $fish_user_paths, persists forever (scope U)
# equivalent to set -Uax fish_user_paths /path/to/bin
# fish variables can be arrays, -a appends to it
There is of course more, but this is just an example of how the syntax feels more mature.
Autosuggestions and syntax highlighting come out of the box on fish
, whereas you need a third-party plugin on bash
or zsh
.
I’ll admit that if you disregard the syntax changes, you can implement pretty much anything you get on fish
with zsh
, using plugins. I can understand using either. I don’t see any compelling reason to ever use bash
.
I use https://github.com/IlanCosman/tide and adore it. It’s beautiful and asynchronous so it won’t slow you down.