Can fish shell interpolate functions when expanding to their full form?

丶灬走出姿态 提交于 2019-12-11 18:25:23

问题


Given the following abbreviation, where git_branch_name returns the current git branch name:

abbr -a ggl 'git pull origin (git_branch_name)'

Is there a way to have the the function interpolate when the abbreviation is expanded?

# 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

回答1:


No, it is not yet possible for an abbreviation to run code when it expands. I expect we'll add this capability before long.




回答2:


You can use a function instead:

function ggl
    commandline 'git pull origin '(git_branch_name)
end

or even a keybinding (Alt + g)

bind \eg 'commandline -i "git pull origin"(git_branch_name)'


来源:https://stackoverflow.com/questions/57919964/can-fish-shell-interpolate-functions-when-expanding-to-their-full-form

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!