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

import-git-aliases doesn't understand multiline aliases #30

Closed henrebotha closed 3 years ago

henrebotha commented 3 years ago

I have aliases that look like this in my .gitconfig.

[alias]
    wkadd = ! "f() { \n\
        git worktree add ../$(echo \"$1\" | sed \"s./.--.g\") $2 -b $1 && \n\
        echo \"$2\" | grep -qv \"^origin/\" || git branch --unset-upstream $1; \n\
        }; f"

When I run abbr import-git-aliases, I get output like this.

Did not import the Git alias `wkadd` because its expansion is a function
Added the global user abbreviation `g$' '$'     'git`
Added the regular user abbreviation `$' '$'     'git`
Added the global user abbreviation `g$' '$'     'echo`
Added the regular user abbreviation `$' '$'     'echo`
Added the global user abbreviation `g$' '$'     '\}\;`
Added the regular user abbreviation `$' '$'     '\}\;`

The first line of course makes sense, but the rest don't.

import-git-aliases should probably be made more aware of multiline aliases so that it knows to skip the whole alias definition if it finds a function alias, and not just the first line of it.

olets commented 3 years ago

Thanks for catching that! And happy to know someone's used import-git-aliases

olets commented 1 month ago

@all-contributors please add @henrebotha for doc and bug

allcontributors[bot] commented 1 month ago

@olets

I've put up a pull request to add @henrebotha! :tada: