Is there a good replacement for !! (bang bang) in fish?

I have recently been trying out fish shell, but one thing I keep running into is fish's lack of the !! command/builtin.

I cannot seem to find a good alternative or replacement for fish. Does one exist?

2

1 Answer

From git-hub -

# Add this to your ~/.config/fish/config.fish
# Syntax:
# To just rerun your last command, simply type '!!'
# '!! sudo' will prepend sudo to your most recent command
# Running !! with anything other than sudo will append the argument to your most recent command
# To add another command to prepend list remove the # on line 10 and put the command in the quotes. Repeat as needed
function !!; set var (history | head -n 1) if test $argv if test $argv = "sudo" #; or "any other command you want to prepend" eval $argv $var else eval $var $argv end else eval $var end
end
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like