Over the last week I setup a Linux VM alongside my current work—I needed decent docker support and also I got somewhat fed up with Windows as a development system.
Setting up a new system means I got to use
sudo a lot, but often I typed a command line and only then realized I had to use
So I added a new editor binding to my
function fish_user_key_bindings fish_default_key_bindings # Prepend sudo to the command line with M-s bind \es sudo-commandline end
~/.config/fish/functions/sudo-commandline.fish looks like this:
function sudo-commandline -d "Insert sudo at the beginning of the command line" set -l cmdline (commandline) commandline -r -- "sudo $cmdline" end
Now I can just type
Alt-S in Fish shell and I get
sudo prepended to my current input.
A small thing, but it already saved me a lot of frustration!