Skip to content

Instantly share code, notes, and snippets.

@cmlsharp
Last active November 26, 2019 11:57
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cmlsharp/77badb2c3455e23b873b to your computer and use it in GitHub Desktop.
Save cmlsharp/77badb2c3455e23b873b to your computer and use it in GitHub Desktop.
Repeat most recent command in fish
# 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 prevcmd (history | head -n 1)
if test "$argv"
if test "$argv" = "sudo" #; or "any other command you want to prepend"
eval "$argv $prevcmd"
else
eval "$var $argv"
end
else
eval "$var"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment