I've been using (and loving) fish shell↗ for a little while now, and I still frequently discover clever behaviors that make my CLI tasks more enjoyable.
Today's discovery: fish will automatically escape single quotes when pasting text↗ into the command line.
If it outputs to the commandline, it will automatically escape the output if the cursor is currently inside single-quotes so it is suitable for single-quotes (meaning it escapes
'and\\).
So if I work up an ugly one-liner for determining the IP address of whatever interface is attached to the default route:
ip addr show $(ip route | grep default | awk '{print $5}') | grep 'inet ' | awk '{print $2}' | cut -d/ -f1
And then decide I'd like to make that into a reusable alias↗, I can copy that line and paste it in after
alias get_ip='
and fish will automagically take care of escaping all those troublesome single quotes
alias get_ip='ip addr show $(ip route | grep default | awk '{print $5}') | grep 'inet ' | awk '{print $2}' | cut -d/ -f1'
Neat!
