jhillyerd / plugin-git

Git aliases plugin for the Fish shell (similar to oh-my-zsh git)
MIT License
608 stars 85 forks source link

List all available git abbreviations and functions #40

Closed wenjoy closed 2 years ago

wenjoy commented 4 years ago

Per title, I cant remember so many shorthand command, I want to list them all in case I cant rember them.

Any suggestion?

jhillyerd commented 4 years ago

There isn't a way, but this is something I've wanted as well. Now that we have our own function for adding abbreviations, we could also have it generate some sort of online documentation.

In the meantime, what I'd recommend is memorizing the common command roots: gb for branches, gc for commits, gd for diff, gl for log, etc. Then you can just gc<tab> to start listing available commit commands.

cmoesel commented 4 years ago

For what it's worth, I'm new to fish, omf, and this plugin (and loving it) but would also really benefit from a feature like this. So, if you're taking votes, count me in!

pibebtol commented 2 years ago

This is actually there (with a little detour). Since this plugin uses abbr to create the abbreviations, you can just call: abbr -s which lists all currently active abbreviations in the session. Conveniently combine it with grep or fzf: abbr -s | grep commit or abbr -s | fzf for filtering 👌

Edit: Sorry, just realized that this is quite an old ticket, so maybe this wasn't available then or is known by now :)

wenjoy commented 2 years ago

@pibebtol It's not late. I think this is accepted answer. Thanks

jhillyerd commented 2 years ago

This will miss out on a few of the functions that are defined outside of abbreviations, but probably good enough.

pibebtol commented 2 years ago

Oh yeah, true, I did not consider this. Also, the abbr -s shows all abbreviations, not only the git related ones. The following command creates an abbreviation that filters the abbreviations for those that start with a g and lists them in fzf. However, I would not want to add this to your repository since it creates a lose dependency to fzf. Do with it what you want! abbr gabbr 'abbr -s | grep ".*--\sg" | fzf'

For the functions: All defined functions in the current shell are listable with the functions command. The following command creates an abbreviation that lists all functions that start with g and opens them in fzf. Picking one shows the implementation of this function. abbr gfunctions 'functions (functions | grep "^g" | fzf)'

This is definitely improvable, but I currently do not want to invest more time into it, take it and do with it whatever you like 😄 If you think, such a function would be interesting for the plugin, ping me and I might take the time to polish it up a little more and create a PR. 👍