有没有什么好的词可以替代 fish 中的 !! (bang bang)?

有没有什么好的词可以替代 fish 中的 !! (bang bang)?

我最近一直在尝试 fish shell,但我一直遇到的一个问题是 fish 缺少命令!!/内置命令。

我似乎找不到鱼的替代品。有这样的替代品吗?

答案1

来自 git-hub -https://gist.github.com/crossroads1112/77badb2c3455e23b873b

# 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

相关内容