sorin-ionescu / prezto

The configuration framework for Zsh
MIT License
13.99k stars 4.49k forks source link

Command to document currently active aliases #377

Closed skarfacegc closed 11 years ago

skarfacegc commented 11 years ago

When I was using omz I had an alias 'gitcmd' that would list all of the currently defined git aliases. I was playing around with adding that, and realized that the currently provided aliases are pretty well documented in the README files. Seems like there should be some way to leverage that.

If it's called findalias

findalias <alias filter> <doc filter>

would look for all aliases that contain the alias filter (for git would return all of the g* aliases) pull the docs for each of those, then list all of the docs that contain the second string.

Thoughts? I find myself constantly doing alias |grep to see what interesting stuff is provided.

something like

% findalias git branch
  - `gb` lists, creates, renames, and deletes branches.
  - `gbc` creates a new branch.
  - `gbl` lists branches and their commits.
  - `gbL` lists local and remote branches and their commits.
  - `gbs` lists branches and their commits with ancestery graphs.
  - `gbS` lists local and remote branches and their commits with ancestery
  - `gbx` deletes a branch.
  - `gbX` deletes a branch irrespective of its merged status.
  - `gbm` renames a branch.
  - `gbM` renames a branch even if the new branch name already exists.
  - `gco` checks out a branch or paths to work tree.
  - `gcf` amends the tip of the current branch using the same log message as
  - `gcF` amends the tip of the current branch.
  - `gfm` fetches from and merges with another repository or local branch.
  - `gfr` fetches from and rebases on another repository or local branch.
  - `gpa` updates remote branches along with associated objects.
  - `gpA` updates remote branches and tags along with associated objects.
     as an upstream reference for the current branch.
  - `gRc` deletes all stale remote tracking branches.
ColinHebert commented 11 years ago

I'm not sure about that, the point of user made aliases is that they are so simple they need little to no documentation at all.

One solution for this issue would be using the alias system provided by git (git config alias.) and the zsh ability to provide some documentation during the completion. Here is what I get with zsh default completion for git <tab>:

 -- alias --
br                  -- alias for 'branch'
ci                  -- alias for 'commit -v'
cia                 -- alias for 'commit --amend -v'
ciaa                -- alias for 'commit -a --amend -v'
co                  -- alias for 'checkout'
df                  -- alias for 'diff'
fap                 -- alias for 'fetch --all -p'
git                 -- alias for '!git'
lg                  -- alias for 'log -p'
log-all             -- alias for '!git log --graph --decorate --pretty=oneline --abbrev-commit --all $(git fsck --no-reflogs | gre
log-merge           -- alias for '!git log $(git merge-base --octopus $(git log -1 --merges --pretty=format:%P $1))..$1 --graph --
lol                 -- alias for '!git --no-pager loll'
lola                -- alias for '!git --no-pager lolal'
lolal               -- alias for 'log --graph --decorate --pretty=oneline --abbrev-commit --all'
loll                -- alias for 'log --graph --decorate --pretty=oneline --abbrev-commit'
ls                  -- alias for 'ls-files'
man                 -- alias for 'help'
remove              -- alias for 'rm'
st                  -- alias for 'status --short'
stasshow            -- alias for 'stash list -p'
stat                -- alias for 'status'
stree               -- alias for '!stree'
unstash             -- alias for 'stash pop'
x                   -- alias for '!gitx'
 -- main porcelain command --
add                 -- add file contents to index
am                  -- apply patches from a mailbox
...
skarfacegc commented 11 years ago

My initial use case was for the 100+ aliases provided by the git plugin, but I was actually thinking somewhat more general for aliases provided in prezto. The documentation is really solid in terms of what's in the README files, was just trying to think how to leverage that from the shell.

sorin-ionescu commented 11 years ago

Perhaps #276 is a good solution for those who do not want to read README files. Man pages are searchable.