Conditional abbreviations #158
Unanswered
rbhanot4739
asked this question in
Q&A
Replies: 1 comment
-
Interesting question! Three solutions come to mind: Put the condition in the abbreviated command itself (wrapping the % abbr ls='command -v eza && { eza -I "*pyc*" $eza_params } || ls' Or use the standard command as a fallback ( % abbr ls='eza -I "*pyc*" $eza_params 2>/dev/null || ls' Or conditionally add session abbreviations when the shell starts: # .zshrc
# load zsh-abbr and then
if …; then
abbr -S …
fi |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Thank you for the amazing plugin, and it works really well. Just wondering if its possible to add certain abbreviations only if the command exists. For example, this is what I have in my aliases file
However, when I import these aliases into abbreviations, this logic isn't respected automatically (which is acceptable and not a big deal). So is it possible to add such
if/else
conditions in the$ABBR_USER_ABBREVIATIONS_FILE
and have an abbreviation defined based on that ?Beta Was this translation helpful? Give feedback.
All reactions