alias - 有没有办法告诉 Fish shell 纠正带有空格的命令中的常见拼写错误?
问题描述
我对 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
推荐阅读
- matlab - 最小二乘法在 MATLAB 中给出次优的 Frobenius 范数
- python - SQL Lite 总行数提取不适用于 Django 模型
- javascript - 如何从字符串中提取Instagram用户名
- xcode - 多个滑块效果不佳?
- php - PHP Regex - 在 Positive Lookbehind 之后匹配多个项目
- webrtc - Janus 网关视频室在 60 秒后取消连接
- sql - 查询连续两个季度的内容
- scrapy - Scrapyd:如何用一个命令取消所有作业?
- php - 如何在 CodeIgniter 4 中创建和加载新的助手
- postgresql - 如何使用 terraform 通过 AWS IAM 身份验证预置 RDS postgres db 用户?