LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   grep through tab completion list results (https://www.linuxquestions.org/questions/linux-general-1/grep-through-tab-completion-list-results-502468/)

tphyahoo 11-17-2006 06:24 AM

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.

Thanks!

matthewg42 11-18-2006 07:34 AM

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
Code:

set |grep ...

David the H. 11-18-2006 08:40 PM

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.

Code:

# 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.


All times are GMT -5. The time now is 12:06 PM.