Using tab in CLI- auto finish, not displaying hidden files and using less
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Using tab in CLI- auto finish, not displaying hidden files and using less
There are a couple of things I have problem with in CLI:
Auto finishing: I really like using the bash shell but one thing the Windows shell (what ever it's called) does better is to let you switch between every file and folder in your pwd using the <TAB>. So if you have a few files with really long and tedious names (imagine a lot of numbers, where a lot of the filenames start the same) or if you have some files starting with letters which aren't on your keyboard you don't have to type in their name but rather use <TAB> to make the first file appear, and then the second one, and the third.. etc. I have encountered both problems in my short Linux career and they are really annoying.
Not display hidden files: Is it possible not to display hidden files when you use the <TAB> key to search for files? Using, for example, the command file or ls in a folder which includes a lot of hidden files (like a home directory), is it possible not to display the hidden files and not get a "Display all 151 something possibilities? (y or n)"
Using something like less: Lastly I was wondering whether it's possible to use something like less to scroll through long results when <TAB> is trying to fill in the gap with something like in problem number 2? Using pipes isn't possible here is it?
I'm sorry if I didn't make my self understandable, I tried to explain it best I could. Basically I'm trying to control the output of <TAB>. It must be possible
There are a couple of things I have problem with in CLI:
Auto finishing: I really like using the bash shell but one thing the Windows shell (what ever it's called) does better is to let you switch between every file and folder in you pwd using the <TAB>. So if you have a few files with really long and tedious names (imagine a lot of numbers, where a lot of the filenames start the same) or if you have some files starting with letters which aren't on your keyboard you don't have to type in their name but rather use <TAB> to make the first file appear, and then the second one, and the third.. etc. I have encountered both problems in my short Linux career and they are really annoying.
Interesting, not sure how to do that... FWIW: I've always found the DOS shell to be 10 times more frustrating!
Quote:
Originally Posted by baldurpet
Not display hidden files: Is it possible not to display hidden files when you use the <TAB> key to search for files? Using, for example, the command file or ls in a folder which includes a lot of hidden files (like a home directory), is it possible not to display the hidden files and not get a "Display all 151 something possibilities? (y or n)"
Using the TAB key? Again, not sure... man bash! What's wrong with ls? If you use SHIFT + PGUP afterwards you can scroll up!
Quote:
Originally Posted by baldurpet
Using something like less: Lastly I was wondering whether it's possible to use something like less to scroll through long results when <TAB> is trying to fill in the gap with something like in problem number 2? Using pipes isn't possible here is it?
I'm sorry if I didn't make my self understandable, I tried to explain it best I could. Basically I'm trying to control the output of <TAB>. It must be possible
Not with TAB (unless I am mistaken) why are you obsessed with the TAB key? Try ls | less
In windows, tab completion was added only lately. Having to cycle though only 1 alternative at a time can be very tedious. Some distro's do a good job with bash completion. When I used Mandrake linux, I was surprised that it would give the proper completions not just for files, but for arguments as well. Such as for "modprobe", the list consisted of modules.
Suppose that you run mplayer. Entering "mplayer" and using tab completion, you get a list of just video files. This context sensitive nature is what makes it very useful.
Interesting, not sure how to do that... FWIW: I've always found the DOS shell to be 10 times more frustrating!
Yes, but just because it's annoying doesn't mean it can't have good points. Once I had select a lot of images which had really long file names and I prayed for a function where you could flip between the files without having to type anything at all.
Quote:
Originally Posted by Tuttle
Using the TAB key? Again, not sure... man bash! What's wrong with ls? If you use SHIFT + PGUP afterwards you can scroll up!
Of course it's possible to use the ls, but it takes more time to use ls first and then to use the tab auto completion. I'm probably just splitting hairs but sometimes when I'm looking for a file or folder in my home directory I get a list that could stretch over more than four monitors, when I'm only looking for files which aren't hidden- which are like 10-15. I just wanted to ask, because this has been annoying me that there isn't an option not to display the hidden files when you auto complete.
I figure that since once of the reasons to use the command line is agility, I might save myself some scrolling if someone were to know an answer.
Quote:
Originally Posted by Tuttle
Not with TAB (unless I am mistaken) why are you obsessed with the TAB key? Try ls | less
Have fun!
Oh.. must admit I misunderstood something here.. Of course the output of the auto completion is displayed in a less sort-of way. Also, I don't know why I'm obsessed with the tab key. Must've been a childhood trauma or maybe I've just started using Linux and want to learn all about it
I find midnight commander (mc) a nice tool... it's a bit like xtree gold... so I'm told...
ps. since we are splitting hairs: I think the TAB key output is like more, in that you need to type "q" to quit less whereas more just quits at EOF... more or less... :P
[*]Not display hidden files: Is it possible not to display hidden files when you use the <TAB> key to search for files? Using, for example, the command file or ls in a folder which includes a lot of hidden files (like a home directory), is it possible not to display the hidden files and not get a "Display all 151 something possibilities? (y or n)"
I've wanted something like this too. I did a quick search and found that adding this to your .bashrc searches only among non-hidden files and folders during completion:
Code:
bind 'set match-hidden-files off'
Tried it, works nice. dotfiles are displayed only when you explicitly enter a period and hit tab.
Auto finishing: I really like using the bash shell but one thing the Windows shell (what ever it's called) does better is to let you switch between every file and folder in your pwd using the <TAB>. So if you have a few files with really long and tedious names (imagine a lot of numbers, where a lot of the filenames start the same) or if you have some files starting with letters which aren't on your keyboard you don't have to type in their name but rather use <TAB> to make the first file appear, and then the second one, and the third.. etc. I have encountered both problems in my short Linux career and they are really annoying.
Found this one as well, in this link. Good old bash does everything
Code:
"\C-i": menu-complete # Cycle through ambiguous completions instead of list
Adding that in /etc/inputrc or ~/.inputrc does the trick. I didn't like the end result of this, though, because the completion list completely disappears and you have to patiently cycle through each hit.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.