Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 11-17-2006, 07:24 AM   #1
LQ Newbie
Registered: Jun 2006
Posts: 4

Rep: Reputation: 0
grep through tab completion list results

When I do $ myname_ << tab tab

I get lots of possibilities. Because I have customized my shell a lot, with the convention that my personal functions usually start with "my name". (It's all under version control, and the first thing I do when I have to start working on a new computer -- and there's a lot of them -- is I check out my "shell environment" so I feel at home.)

I'm wondering if there's a way I can "grep" through the tab completion list, to narrow down the list of possibilities if there is some function/alias I can remember having written, but I can't remember exactly how I named it.

Old 11-18-2006, 08:34 AM   #2
Senior Member
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
Not sure about filtering the tab completion list (I'd love to know if there is a way), but you can check for specific environment variables by doing
set |grep ...
Old 11-18-2006, 09:40 PM   #3
David the H.
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian + kde 4 / 5
Posts: 6,834

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
This may not be exactly what you want, but I found this code snippet for your bashrc file on some "tips & tricks" thread a while back that's supposed to show you all the previous entries for a command in your history. However for some reason it never worked for me. Maybe it'll do something for you.

# user added binds to special keys:
# <Alt>+w to show all possible completions for a command from history.
bind '"\M-w"':"\"\C-k\C-ahistory | grep '^ *[0-9]* *\C-e.'\C-m\""
In the meantime, at least there's always <crtl>-r and <crtl>-s for searching backwards and forwards through your history.

If you know something about scripting, there should be an /etc/bash_completion file that has all sorts of code controlling what gets completed and what doesn't. Don't ask me how it all works though.


grep, readline

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Tab completion with sudo extrasolar Slackware 8 08-22-2006 03:46 PM
adding an option to a 'tab' completion + ls whatnoname Linux - Newbie 2 06-07-2005 08:32 AM
tab completion with scp fsbooks Linux - General 5 04-07-2005 04:13 PM
How can I turn on/install tab completion which I am so used to. jimdaworm *BSD 2 04-07-2005 12:25 AM
apt-get tab completion atheist Debian 6 06-11-2004 09:25 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:03 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration