Closed yutkat closed 3 years ago
Thanks for the idea! At this time I'm not comfortable supporting evaluation in that way. Seems like a vector for easy abuse.
If you just need the result, you can use the default expand-and-accept behavior
abbr -g gr="git rev-parse --show-cdup"
gr
If you need to use the result in a command and don't care about seeing the full text of the command, that's a good use case for an alias
% alias -g gr="git rev-parse --show-cdup"
% cd my-repo/dir
% gr
../
% cat $(gr)README.md
# snip
% cd $(gr)
I see the limitation if you do want to see the full command and it needs to not be followed by a space, for example in the above cat $(git rev-parse --show-cdup)README.md
example. Currently you can
abbr -g gr='$(git rev-parse --show-cdup)'
gr<Space><Delete>README.md<Enter>
which is okay but it'd be nice to document a way of expanding in place, without having to delete a space:
abbr -g gr='$(git rev-parse --show-cdup)'
gr<some binding>README.md<Enter>
I'll plan on adding that feature.
p.s. nice GH landing page!
I'll try to workaround it for now.
Thank you for your reply :wink:
Added some friendlier widget names, see https://github.com/olets/zsh-abbr#bindings
Closing but let me know if that doesn't meet your needs
I'd like to define abbr as follows.
abbr add --quiet -g gr='$(git rev-parse --show-cdup)'
ref: https://github.com/momo-lab/zsh-abbrev-alias#help
-e, --eval evaluates subshells on expansion.