Question Regarding Tab Completion in Bash
I noticed something with the bash shell recently (might be old and just never really noticed it before) If I have 3 files in a directory, such as follows: file_1.tar file_2.tar file_3.tar.gz If I type 'gzip -df file' and then hit TAB to start path completion, it knows to select the file_3.tar.gz because it is the only file with a *.gz extension. (I am assuming) Just curious where this new functionality was implemented. Is this done to bash itself or via some other mechanism? I am looking to do something like this for some code I am writing... Thx, cc
On Wed 17 November 2004 16:57, Rhugga wrote:
I noticed something with the bash shell recently (might be old and just never really noticed it before)
If I have 3 files in a directory, such as follows:
file_1.tar file_2.tar file_3.tar.gz
If I type 'gzip -df file' and then hit TAB to start path completion, it knows to select the file_3.tar.gz because it is the only file with a *.gz extension. (I am assuming) Just curious where this new functionality was implemented. Is this done to bash itself or via some other mechanism?
I am looking to do something like this for some code I am writing...
Thx, cc
Take a look in: /etc/profile.d/complete.bash Also, try 'man bash' and search for 'completion' for the rules that are used to complete a word. HTH jalal -- GPG fingerprint = 3D45 5509 D380 26A4 523E A9D8 A66A 5F38 CA43 BB0E
On Wednesday 17 November 2004 16:57, Rhugga wrote:
I noticed something with the bash shell recently (might be old and just never really noticed it before)
If I have 3 files in a directory, such as follows:
file_1.tar file_2.tar file_3.tar.gz
If I type 'gzip -df file' and then hit TAB to start path completion, it knows to select the file_3.tar.gz because it is the only file with a *.gz extension. (I am assuming) Just curious where this new functionality was implemented. Is this done to bash itself or via some other mechanism?
You mean /etc/bash_completion.d? (9.2) Cheers, Leen
jalal wrote:
On Wed 17 November 2004 16:57, Rhugga wrote:
I noticed something with the bash shell recently (might be old and just never really noticed it before)
If I have 3 files in a directory, such as follows:
file_1.tar file_2.tar file_3.tar.gz
If I type 'gzip -df file' and then hit TAB to start path completion, it knows to select the file_3.tar.gz because it is the only file with a *.gz extension. (I am assuming) Just curious where this new functionality was implemented. Is this done to bash itself or via some other mechanism?
I am looking to do something like this for some code I am writing...
Thx, cc
Take a look in: /etc/profile.d/complete.bash
Also, try 'man bash' and search for 'completion' for the rules that are used to complete a word.
HTH jalal
Why does no one ever hint to 'info bash'? In this case, it's much more convenient than the plain old man page. And if there's no specific info node, at least it comes up with the man page anyway. No offense meant, I just note that here and in other lists the supplicant is usually told to use 'man foo' where info would be better. KK
On Thursday 18 November 2004 02:41, Kolja Kauder wrote:
Why does no one ever hint to 'info bash'? In this case, it's much more convenient than the plain old man page. And if there's no specific info node, at least it comes up with the man page anyway. No offense meant, I just note that here and in other lists the supplicant is usually told to use 'man foo' where info would be better.
And even better still - at least for those less experienced in keyboard navigation - is to use man:/bash or info:/bash as URLs in konqueror. A nicely navigatable page
KK, On Wednesday 17 November 2004 17:41, Kolja Kauder wrote:
...
Why does no one ever hint to 'info bash'? In this case, it's much more convenient than the plain old man page.
That is a matter of opinion. I personally find a nice, linear document presented either in a scrolling viewer or via a pager like "less" to be much more accessible than that idiosyncratic "info" contraption.
...
KK
Randall Schulz
Randall R Schulz wrote:
KK,
On Wednesday 17 November 2004 17:41, Kolja Kauder wrote:
...
Why does no one ever hint to 'info bash'? In this case, it's much more convenient than the plain old man page.
That is a matter of opinion. I personally find a nice, linear document presented either in a scrolling viewer or via a pager like "less" to be much more accessible than that idiosyncratic "info" contraption.
Yes, for a short lookup that's the same for me, but things like hyperlinks and a concept index are very handy if you're looking for a more 'fuzzy' feature. I've looked it up and in this case here it makes no difference but it helped me very much with other bash (and libc, binutils, ...) issues. Plus, I prefer emacs ;-) Kolja
* Anders Johansson
On Thursday 18 November 2004 03:13, Anders Johansson wrote:
A nicely navigatable page
navigatable? navigatatatable? Oh, I gotta stop sleeping in the park
navigable -- Patrick Shanahan Registered Linux User #207535 http://wahoo.no-ip.org @ http://counter.li.org HOG # US1244711 Photo Album: http://wahoo.no-ip.org/photos
* Kolja Kauder
Yes, for a short lookup that's the same for me, but things like hyperlinks and a concept index are very handy if you're looking for a more 'fuzzy' feature. I've looked it up and in this case here it makes no difference but it helped me very much with other bash (and libc, binutils, ...) issues. Plus, I prefer emacs ;-)
And for those not privy to the intricate and varied key-stroke combinations of emacs, there is pinfo which is *easy*. -- Patrick Shanahan Registered Linux User #207535 http://wahoo.no-ip.org @ http://counter.li.org HOG # US1244711 Photo Album: http://wahoo.no-ip.org/photos
On Thursday 18 November 2004 05:08, Patrick Shanahan wrote:
* Anders Johansson
[11-17-04 22:49]: On Thursday 18 November 2004 03:13, Anders Johansson wrote:
A nicely navigatable page
navigatable? navigatatatable? Oh, I gotta stop sleeping in the park
navigable
New type of cable? Cheers, Leen
On Wednesday 17 November 2004 08:41 pm, Kolja Kauder wrote:
Why does no one ever hint to 'info bash'? In this case, it's much more convenient than the plain old man page. And if there's no specific info node, at least it comes up with the man page anyway. No offense meant, I just note that here and in other lists the supplicant is usually told to use 'man foo' where info would be better.
info is an abomination in my opinion. It is very non-intuitive and I'm sorry, I don't want to take the time to learn it. (if possible) I tried an info file just this week and had a hard time fighting my way out of it. Using Konqy to read an info file isn't bad.... but doesn't work in a console session or any place where konqy isn't. Just my $.02
Anders Johansson wrote:
On Thursday 18 November 2004 02:41, Kolja Kauder wrote:
Why does no one ever hint to 'info bash'? In this case, it's much more convenient than the plain old man page. And if there's no specific info node, at least it comes up with the man page anyway. No offense meant, I just note that here and in other lists the supplicant is usually told to use 'man foo' where info would be better.
And even better still - at least for those less experienced in keyboard navigation - is to use
man:/bash
or
info:/bash
as URLs in konqueror. A nicely navigatable page
In Konqueror, <ALT>F2 then #bash for man page or ##bash for info.
* Leendert Meyer
New type of cable?
To attach an audio tape device for storage on my C64. -- Patrick Shanahan Registered Linux User #207535 http://wahoo.no-ip.org @ http://counter.li.org HOG # US1244711 Photo Album: http://wahoo.no-ip.org/photos
Patrick, On Wednesday 17 November 2004 20:18, Patrick Shanahan wrote:
* Kolja Kauder
[11-17-04 23:13]: Yes, for a short lookup that's the same for me, but things like hyperlinks and a concept index are very handy if you're looking for a more 'fuzzy' feature. I've looked it up and in this case here it makes no difference but it helped me very much with other bash (and libc, binutils, ...) issues. Plus, I prefer emacs ;-)
And for those not privy to the intricate and varied key-stroke combinations of emacs, there is pinfo which is *easy*.
And virtually unreadable, given the black background and dark text (blue, red and grey, by default). I would have thought the manifest superiority of dark text on a light background would have pervaded UI design by now.
-- Patrick Shanahan
Randall Schulz
* Randall R Schulz
And virtually unreadable, given the black background and dark text (blue, red and grey, by default). I would have thought the manifest superiority of dark text on a light background would have pervaded UI design by now.
agreed, the default color scheem is less than desirable in an xterm window, but not toooo bad in in a console. The man page (here I go again) indicates that the colors are user definable and exist in ~/.pinforc and/or /etc/pinforc. Examples are given. In fact, you may redefine the default key-bindings and some options. man pages seem to provide a veritable wealth of information <grin>. -- Patrick Shanahan Registered Linux User #207535 http://wahoo.no-ip.org @ http://counter.li.org HOG # US1244711 Photo Album: http://wahoo.no-ip.org/photos
Patrick, On Thursday 18 November 2004 12:27, Patrick Shanahan wrote:
* Randall R Schulz
[11-18-04 15:03]: And virtually unreadable, given the black background and dark text (blue, red and grey, by default). I would have thought the manifest superiority of dark text on a light background would have pervaded UI design by now.
agreed, the default color scheem is less than desirable in an xterm window, but not toooo bad in in a console.
I was using Konsole, actually.
The man page (here I go again) indicates that the colors are user definable and exist in ~/.pinforc and/or /etc/pinforc. Examples are given. In fact, you may redefine the default key-bindings and some options.
I'd assumed it was so, but didn't bother looking for the details because I still don't care for non-linear text for purposes of this kind of document. The man pages are still my preferred format. I resort to the "info" system only when the man page indicates that it is incomplete and that for full details I must refer to the info documents.
man pages seem to provide a veritable wealth of information <grin>.
As ever.
-- Patrick Shanahan
Randall Schulz
Bruce Marshall wrote:
info is an abomination in my opinion. It is very non-intuitive and I'm sorry, I don't want to take the time to learn it. (if possible)
I tried an info file just this week and had a hard time fighting my way out of it.
Using Konqy to read an info file isn't bad.... but doesn't work in a console session or any place where konqy isn't.
Just my $.02
Agreed! and I want to add two more cents :-) I usually check bash manpage to remember the syntax of some shell script commands (if, case, while, etc). As 'case' being a somewhat rare word in texts, I type: $ man bash<enter> /case<enter> nn and I reached the right section. Using info: $ info bash look for "Basic Shell Features" look for "Shell Commands" look for "Conditional Constructs" another way could be like that: $ info bash look for "Reserved Word Index" look for "case" (the first that will bring "Conditional Constructs" page) much more difficult to remember, not to mention my classification problem: 'if' should be under "Shell Builtin Commands" or "Basic Shell Features"? -- Marcos Lazarini
Marcos Lazarini wrote:
Bruce Marshall wrote:
info is an abomination in my opinion. It is very non-intuitive and I'm sorry, I don't want to take the time to learn it. (if possible)
Well, how is "Ctrl-S" (for incremental search) less intuitive than "/"? It's a matter of taste in the end, and is connected to the old vi vs. emacs war.
I tried an info file just this week and had a hard time fighting my way out of it.
Try "q"... shouldn't be so hard to find ;-)
Using Konqy to read an info file isn't bad.... but doesn't work in a console session or any place where konqy isn't.
Just my $.02
Agreed! and I want to add two more cents :-)
I usually check bash manpage to remember the syntax of some shell script commands (if, case, while, etc).
As 'case' being a somewhat rare word in texts, I type: $ man bash<enter> /case<enter> nn and I reached the right section.
Using info: $ info bash look for "Basic Shell Features" look for "Shell Commands" look for "Conditional Constructs"
another way could be like that: $ info bash look for "Reserved Word Index" look for "case" (the first that will bring "Conditional Constructs" page)
I can construct examples like that, too. Try finding the syntax of "if"...
much more difficult to remember, not to mention my classification problem: 'if' should be under "Shell Builtin Commands" or "Basic Shell Features"?
Well, try the indexes than! That's what they're for. In this case the first index "Reserved Word Index" does the trick.
-- Marcos Lazarini
Kolja
participants (10)
-
Anders Johansson
-
Bruce Marshall
-
jalal
-
James Knott
-
Kolja Kauder
-
Leendert Meyer
-
Marcos Lazarini
-
Patrick Shanahan
-
Randall R Schulz
-
Rhugga