I'm a little sore that the FAQ Listed that as an alternative. That was how I did it in bash before I realized I could do "sudo !!" which was waaaaay more convenient.
It's a step backwards. Which I'm fine with, as long as you step forward again, in some way.
that works just as well I guess. But what if I want to make an alias for "sudo the last command"?
https://github.com/fish-shell/fish-shell/issues/288#issuecom... has some options.
Re:Fish 2.0 shell beta
by pooriaazimi on Wednesday April 17, 2013 @11:06PM
(#5568716)
Wonderful!
I made a slight variation (and also posted it there):
function .runsudo --description 'Run current command line as root'
set cursor_pos (echo (commandline -C) + 5 | bc)
commandline -C 0
commandline -i 'sudo '
commandline -C "$cursor_pos"
end
bind \es ".runsudo"
Instead of outright `execute`ing the command, the above would save the cursor position. You can (theoretically) bind `\cs` so control-s adds the sudo (instead of option-s), but I couldn't get it to work.
I was interested in this comment so I looked into the documentation to find out why this is. Here's a link to the FAQ for anyone else interested:
http://ridiculousfish.com/shell/user_doc/html/faq.html#faq-h... (last question)