Automatic Help for Your Shell Aliases

A few days ago I have discovered dotree , a nice litte tool that “wants to be a better home for your aliases and bash functions”.

This made me think: do I really need another tool or can I obtain a similar result with a zsh function?

So armed with impatience I have asked ChatGPT to write the al function. After a bit of tweaking the resulting code is fairly decent and does the job. You can find it in this gist .


I have my aliases defined in ~/.zsh/zalias like this:

1## Misc
2alias llg='ls -l | grep'      # List files and grep
3alias lag='ls -la | grep'     # List hidden files and grep
4
5## Manjaro
6alias pci='sudo pacman -Sy'   # Install a package
7alias pcr='sudo pacman -R'    # Remove a package
8alias pcu='yay -Syu'          # Update packages

Executing al I am presented with the following menu:

1Select a category:
21) Misc
32) Manjaro
4?#

Selecting category 2) Manjaro:

1Select an alias from 'Manjaro':
22) pci: install a package
33) pcr: remove a package
44) pcu: update packages
5?#

and finally selecting 4) pcu the alias command is displayed in case we want to inspect it

1yay -Syu

Differently from dotree, this function does not execute the selected command because most of my aliases require additional arguments so it would not make sense to executed them from the menu.


Boot a Windows Partition From Linux Using KVM