BASH auto-complete of command names

How to get a list of all commands

Page 1 of 1

3 Replies - 2260 Views - Last Post: 21 December 2007 - 09:31 PM Rate Topic: -----

#1 ericode  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 7
  • View blog
  • Posts: 112
  • Joined: 09-December 06

BASH auto-complete of command names

Post icon  Posted 16 December 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.

Is This A Good Question/Topic? 0
  • +

Replies To: BASH auto-complete of command names

#2 ericode  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 7
  • View blog
  • Posts: 112
  • Joined: 09-December 06

Re: BASH auto-complete of command names

Posted 18 December 2007 - 11:40 PM

Well, I was able to come up with a script to somewhat do this, I put the script in the snippets at http://www.dreaminco...snippet1537.htm

It doesn't do everything though, because if there are some built in bash commands, this script won't find them.
Was This Post Helpful? 0
  • +
  • -

#3 no2pencil  Icon User is offline

  • Toubabo Koomi
  • member icon

Reputation: 5316
  • View blog
  • Posts: 27,220
  • Joined: 10-May 07

Re: BASH auto-complete of command names

Posted 19 December 2007 - 04:49 AM

View Postericode, on 16 Dec, 2007 - 07:31 PM, said:

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...?
Was This Post Helpful? 0
  • +
  • -

#4 ericode  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 7
  • View blog
  • Posts: 112
  • Joined: 09-December 06

Re: BASH auto-complete of command names

Posted 21 December 2007 - 09:31 PM

View Postno2pencil, on 19 Dec, 2007 - 04:49 AM, said:

View Postericode, on 16 Dec, 2007 - 07:31 PM, said:

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.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1