olets / zsh-abbr

The zsh manager for auto-expanding abbreviations, inspired by fish. ~13,000 unique cloners as of May '24, 580+ Homebrew installs 6/23-6/24
https://zsh-abbr.olets.dev
Other
510 stars 18 forks source link

Respect multiline Git aliases #31

Closed henrebotha closed 3 years ago

henrebotha commented 3 years ago

It is possible to define a Git alias that contains line breaks. Previously, this would result in zsh-abbr attempting to parse each individual line as if it were a separate alias, resulting in lots of errors. The cause of this was splitting the output of git config --get-regexp on line breaks.

This change splits the output of git config --get-regexp on newlines followed by the string "alias.", thereby ensuring that an alias that takes multiple lines gets treated as a unit.

Unfortunately this splitting doesn't get rid of the prefix "alias." on the very first alias, and so we need to retain the substitution that gets rid of this prefix.

Resolves #30.

henrebotha commented 3 years ago

Oh, this isn't an external command. ${(f)"$(foo)"} is short for ${(ps|\n|)"$(foo)"}, which is just a Zsh parameter expansion (see "Parameter Expansion Flags" in man zshexpn), so I'm doing virtually the same thing here, just replacing the pattern \n with \nalias..

olets commented 3 years ago

Oh yes I read to hastily. Thought I was seeing ps | …. Great, will move forward with this later today

olets commented 3 years ago

Released in v4.2.0

Thanks for the contribution!