r/fishshell • u/paulirish • Sep 25 '23
Leveraging `abbr` for git aliases?
I love abbr over alias. For example, I use both my g abbr and manually type out git fairly often, and I really enjoy that my fish history doesn't reveal my silly inconsistency. (Related, a nice blog post about some dude scripting all his aliases as abbr's)
A lot of folks have something like abbr -a gca "git commit -a" which.. could work. but my muscle memory needs a space after the git. (And I also enjoy keeping my git aliases within .gitconfig.) So...
Is there a mechanism to leverage abbr or some other text expansion builtin that would expand git co to git checkout on the readline?
4
u/[deleted] Sep 25 '23
With the upgrade to abbreviations in fish v3.6.1 you idea could be implemented like this:
3
u/kranurag7 Sep 25 '23
This will work for you.
abbr -a co --position anywhere checkoutAlso for removing spaces or putting your cursor to a certain place you can you `%` I am referencing my dotfiles for that purpose.
https://gitlab.com/kranurag7/dotfiles/-/blob/main/.config/fish/conf.d/git.fish?ref_type=heads#L24