Skip to content
Discussion options

You must be logged in to vote

Interesting question!

Three solutions come to mind:

Put the condition in the abbreviated command itself (wrapping the if condition in {} prevents its exit code from affecting whether the else is reached).

% abbr ls='command -v eza && { eza -I "*pyc*" $eza_params } || ls'

Or use the standard command as a fallback (2>/dev/null prevents the "zsh: command not found" output from showing in your terminal)

% abbr ls='eza -I "*pyc*" $eza_params 2>/dev/null || ls'

Or conditionally add session abbreviations edit: abbreviations when the shell starts:

# .zshrc

# load zsh-abbr and then

if; then
  # edit: this is what I said originally
  # abbr -S …
  # but in retrospect (see henrebotha's response)…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@henrebotha
Comment options

@olets
Comment options

olets Apr 1, 2026
Maintainer

@henrebotha
Comment options

Answer selected by olets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants