fish shell 可以在扩展到完整形式时插入函数吗?
Can fish shell interpolate functions when expanding to their full form?
给定以下缩写,其中 git_branch_name
returns 当前 git 分支名称:
abbr -a ggl 'git pull origin (git_branch_name)'
有没有办法让函数在扩展缩写时进行插值?
# This is what the abbreviation expands to
$ git pull origin (git_branch_name)
# This is the expansion I am looking for
$ git pull origin master
不,运行 代码在扩展时还不能缩写。我希望我们很快就会添加此功能。
您可以改用函数:
function ggl
commandline 'git pull origin '(git_branch_name)
end
甚至是快捷键 (Alt + g)
bind \eg 'commandline -i "git pull origin"(git_branch_name)'
这种能力现在存在于鱼身上! Pierre Spring的具体例子,在fish 3.2.2中,缩写
abbr -a ggl git pull origin (git_branch_name)
将扩展到
git pull origin master
广义案例如下所示:
创建自定义函数 foo.fish returns bar
function foo
echo bar
end
添加一个缩写“rtb”,当它扩展时,将通过管道传递函数 foo
的结果
abbr -a rtb echo raise the (foo)
现在,在命令行中输入 rtb
将:
- 扩展为命令
echo raise the bar
- return结果
raise the bar
给定以下缩写,其中 git_branch_name
returns 当前 git 分支名称:
abbr -a ggl 'git pull origin (git_branch_name)'
有没有办法让函数在扩展缩写时进行插值?
# This is what the abbreviation expands to
$ git pull origin (git_branch_name)
# This is the expansion I am looking for
$ git pull origin master
不,运行 代码在扩展时还不能缩写。我希望我们很快就会添加此功能。
您可以改用函数:
function ggl
commandline 'git pull origin '(git_branch_name)
end
甚至是快捷键 (Alt + g)
bind \eg 'commandline -i "git pull origin"(git_branch_name)'
这种能力现在存在于鱼身上! Pierre Spring的具体例子,在fish 3.2.2中,缩写
abbr -a ggl git pull origin (git_branch_name)
将扩展到
git pull origin master
广义案例如下所示:
创建自定义函数 foo.fish returns bar
function foo echo bar end
添加一个缩写“rtb”,当它扩展时,将通过管道传递函数 foo
的结果abbr -a rtb echo raise the (foo)
现在,在命令行中输入
rtb
将:- 扩展为命令
echo raise the bar
- return结果
raise the bar
- 扩展为命令