Is there a Linux command that will list all available commands and aliases for this terminal session?
As if you typed 'a' and pressed tab, but for every letter of the alphabet. Or running 'alias' but also returning commands.
Why? I'd like to run the following and see if a command is available:
ListAllCommands | grep searchstr
it depends, by that I mean it depends on what shell you are using. here are the constraints I see:
I use ZSH so here is a zsh answer, it does the following 3 things:
here it is:
If you use zsh this should do it.
Here's a function you can put in your bashrc file:
Example usage:
FYI: IFS is a variable that bash uses to split strings.
Certainly there could be some better ways to do this.
Alternatively, you can get a convenient list of commands coupled with quick descriptions (as long as the command has a man page, which most do):
Then you just grep it like you want.
yields:
The results don't appear to be sorted, so if you're looking for a long list, you can throw a | sort | into the middle, and then pipe that to a pager like less/more/most. ala:
Which returns a sorted list of all commands that have "zip" in their name or their short description, and pumps that the "less" pager. (You could also replace "less" with $PAGER and use the default pager.)
shortcut method to list out all commands. Open terminal and press two times "tab" button. Thats show all commands in terminal
The problem is that the tab-completion is searching your path, but all commands are not in your path.
To find the commands in your path using bash you could do something like :
for x in
echo $PATH | cut -d":" -f1
; do ls $x; done