Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,158 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,946 people online right now. Registration is fast and FREE... Join Now!




BASH auto-complete of command names

 
Reply to this topicStart new topic

BASH auto-complete of command names, How to get a list of all commands

ericode
16 Dec, 2007 - 06:31 PM
Post #1

D.I.C Head
Group Icon

Joined: 9 Dec, 2006
Posts: 89


Dream Kudos: 75
My Contributions
When in bash, I can type the beginning of a command name (which is not necessarily in the current directory), hit tab a couple times, and a list of commands is displayed which start with what I have typed (almost looks like the list is being displayed with 'more', but I have to press Enter to scroll down the list).

My question is this, how does this functionality work? I want to be able to get a list of all commands that are auto-complete-able via hitting tab twice, so that I can pipe it to a file or grep.
User is offlineProfile CardPM
+Quote Post

ericode
RE: BASH Auto-complete Of Command Names
18 Dec, 2007 - 10:40 PM
Post #2

D.I.C Head
Group Icon

Joined: 9 Dec, 2006
Posts: 89


Dream Kudos: 75
My Contributions
Well, I was able to come up with a script to somewhat do this, I put the script in the snippets at http://www.dreamincode.net/code/snippet1537.htm

It doesn't do everything though, because if there are some built in bash commands, this script won't find them.
User is offlineProfile CardPM
+Quote Post

no2pencil
RE: BASH Auto-complete Of Command Names
19 Dec, 2007 - 03:49 AM
Post #3

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 6,446



Thanked: 66 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
QUOTE(ericode @ 16 Dec, 2007 - 07:31 PM) *

When in bash, I can type the beginning of a command name (which is not necessarily in the current directory), hit tab a couple times, and a list of commands is displayed which start with what I have typed (almost looks like the list is being displayed with 'more', but I have to press Enter to scroll down the list).

My question is this, how does this functionality work? I want to be able to get a list of all commands that are auto-complete-able via hitting tab twice, so that I can pipe it to a file or grep.


Why can't you just run a find with the start of the file name, against your path, or /usr/bin,/usr/sbin & pipe that with grep? Or an ls...?
User is online!Profile CardPM
+Quote Post

ericode
RE: BASH Auto-complete Of Command Names
21 Dec, 2007 - 08:31 PM
Post #4

D.I.C Head
Group Icon

Joined: 9 Dec, 2006
Posts: 89


Dream Kudos: 75
My Contributions
QUOTE(no2pencil @ 19 Dec, 2007 - 04:49 AM) *

QUOTE(ericode @ 16 Dec, 2007 - 07:31 PM) *

When in bash, I can type the beginning of a command name (which is not necessarily in the current directory), hit tab a couple times, and a list of commands is displayed which start with what I have typed (almost looks like the list is being displayed with 'more', but I have to press Enter to scroll down the list).

My question is this, how does this functionality work? I want to be able to get a list of all commands that are auto-complete-able via hitting tab twice, so that I can pipe it to a file or grep.


Why can't you just run a find with the start of the file name, against your path, or /usr/bin,/usr/sbin & pipe that with grep? Or an ls...?


Right, that is what I want to do, but I want to do it for every directory in my $PATH. I read through the man page for find a couple times and couldn't find an option that would accept a list of directories.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/1/08 11:40PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month