问题
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