Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List all aliases available in fish/bash shell

Tags:

Is there a way to list all aliases, something like:

$ ls-aliases
.. "cd .."
la "ls -Gla"
gs "git stash"
etc...

Also is it possible to add human readable descriptions to aliases ?

I'm on a MacOSX

like image 681
Labithiotis Avatar asked Oct 09 '16 09:10

Labithiotis


People also ask

How do I see all aliases in bash?

All you need to do is type alias at the prompt and any active aliases will be listed. Aliases are usually loaded at initialization of your shell so look in . bash_profile or . bashrc in your home directory.

How do I view all aliases in Linux?

To see a list of aliases set up on your linux box, just type alias at the prompt. You can see there are a few already set up on a default Redhat 9 installation. To remove an alias, use the unalias command.

Where are bash aliases saved?

You need to put bash shell aliases in the ~/. bashrc file ($HOME/. bashrc) file executed by bash for non-login shells. On most modern Linux distros, you may want to put all your bash alias definitions into a separate file like ~/.


2 Answers

In bash:

To list all aliases:

alias

To add a comment, just put it at the end of the command, e.g.:

$ alias foo='echo bar #some description'

$ foo
bar

$ alias foo
alias foo='echo bar #some description'
like image 75
heemayl Avatar answered Sep 18 '22 13:09

heemayl


Note that in fish the alias command creates a function using the alias name that wraps the alias value. So there isn't currently any way to list just "aliases". You can use the functions command to list the names of all the defined functions (which by definition includes aliases). If you want the names one per line just functions | cat.

like image 20
Kurtis Rader Avatar answered Sep 19 '22 13:09

Kurtis Rader