Friendly Interactive Shell
Dotfiles
Fish is my main shell, and while I like it as a shell, I don't like it as a language. I do think it's a brilliant exercise in design, to get a shell language to as clean and legible a syntax as, say, Lua or Python, but... the tradeoff is it's so verbose to perform the simplest of operations.
I should really just publish my dotfiles wholly, but they contain a few highly-specialised and therefore incomprehensible components, as well as some commercial elements like paid-for plugins and scripts for different programs. In the absence of that, though, I have put a few scripts from them in the /txt/ pages.
Tricks and one-liners
Setting a default value for an input
test -z $width; and set -l width 680If the width variable is set, it will be used, else it will be 680. For instance, from my dotfiles, making a GIF quickly —
function quickgif -a input -a output -a start -a length -a width
test -z $width; and set -l width 680
set -l filter (printf "fps=12,scale=%d:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" $width)
ffmpeg -hide_banner -loglevel warning -threads 0 -i $input -ss $start -t $length -vf $filter $output
endIn usage, this looks like the following, where the final width value may be left blank —
quickgif input.mp4 output.gif 02:05 7 480