我是Fish的新手,到目前为止我很喜欢它,但我很恼火缩写不能有空格。例如,当我键入git statsu
时(这比git status
的实际命令更频繁(,我希望它用正确的命令替换文本。我已尝试将以下内容添加到我的config.fish
文件中:
abbr "git statsu" "git status"
…这给了我:
abbr --add: Abbreviation 'git statsu' cannot have spaces in the word
第二次尝试(不支持带有空格的别名(:
alias "git statsu"="git status"
- (line 1): function: Unexpected positional argument 'statsu'
function git statsu --wraps 'git status' --description 'alias git statsu=git status'; git status $argv; end
^
from sourcing file -
called on line 61 of file /usr/share/fish/functions/alias.fish
in function 'alias' with arguments 'git statsu=git status'
called on line 19 of file ~/.config/fish/config.fish
from sourcing file ~/.config/fish/config.fish
called on line 1 of file -
in function 'config'
同样,我尝试:
alias "git statsu"="git status"
哪个默默失败:
> git statsu
git: 'statsu' is not a git command. See 'git --help'.
The most similar command is
status
最后(第一个参数后的缩写未展开(:
abbr statsu status
> git statsu
git: 'statsu' is not a git command. See 'git --help'.
The most similar command is
status
请提供替代解决方案;我厌倦了不断输入错误的命令,不得不手动更正。
为什么不使用git别名呢。下面是我的几个:
$ cat ~/.gitconfig
...
[alias]
co = checkout
stat = status
这里有一个你可以做的鱼的事情,很容易用其他常见的打字错误扩展:
function git
switch $argv[1]
case statsu
set argv[1] status
end
command git $argv
end