CLI Magic: Bash complete (Linux.com)
The auto complete feature of the Bourne Again SHell makes bash one of the most loved and newbie-friendly Linux shells. Just by pressing the Tab key you can complete commands and filenames. Press the Tab key twice and all files in the directory get displayed. But you can do more with autocomplete -- such as associating file types with applications, and automatically designating whether you're looking for directories, text, or MP3 files. With simple commands such as complete and the use of Escape sequences, you can save time and have fun on the command line."
Posted May 8, 2006 21:30 UTC (Mon)
by stijn (subscriber, #570)
[Link] (1 responses)
Posted May 9, 2006 14:19 UTC (Tue)
by tjc (guest, #137)
[Link]
bind '"\t":menu-complete'
Posted May 9, 2006 11:48 UTC (Tue)
by liljencrantz (guest, #28458)
[Link]
I am biased since I am the author of fish, but I would say that fish is much more newbie friendly than bash. Newbie friendly touches that fish has that bash lacks include:
Posted May 9, 2006 13:52 UTC (Tue)
by Richard_J_Neill (subscriber, #23093)
[Link] (8 responses)
Edit ~/.inputrc and add:
Mandriva is the only distro I have tried that gets this right. It's far more helpful. And the system-bell is then meaningful on the occasions when it is used. (Redhat,Debian,Ubuntu get it 'wrong').
if using Konsole, you probably want to use the System Bell (= pcspkr) rather than System Notification (= arts)
Posted May 9, 2006 14:48 UTC (Tue)
by sholden (guest, #7881)
[Link] (5 responses)
Of course I also have directories with tens of thousands of files in them (over NFS) and you might as well go make some coffee if you double tab in one of those...
Posted May 9, 2006 16:36 UTC (Tue)
by Richard_J_Neill (subscriber, #23093)
[Link] (4 responses)
Ah. Bash is smarter than that! It will ask you for confirmation before trying to print out more than about 100 completions.
Add the bash-completion package, and you can even complete on PIDs, signals, Hostnames,Variables, package-names....
Eg: urpmi moz[TAB] -> illa
Posted May 9, 2006 16:59 UTC (Tue)
by jhardin@impsec.org (guest, #15045)
[Link] (3 responses)
Posted May 9, 2006 17:18 UTC (Tue)
by iabervon (subscriber, #722)
[Link] (2 responses)
Posted May 10, 2006 14:20 UTC (Wed)
by tjc (guest, #137)
[Link] (1 responses)
Posted May 12, 2006 12:06 UTC (Fri)
by nix (subscriber, #2304)
[Link]
Posted May 9, 2006 15:59 UTC (Tue)
by afalko (guest, #37028)
[Link] (1 responses)
Posted May 9, 2006 22:07 UTC (Tue)
by NapalmLlama (guest, #26327)
[Link]
I'm on Gentoo and if I turn the bell on BASH beeps at me all the time...
Posted May 9, 2006 19:17 UTC (Tue)
by dann (guest, #11621)
[Link] (2 responses)
Posted May 9, 2006 22:02 UTC (Tue)
by micampe (guest, #4384)
[Link] (1 responses)
Posted May 10, 2006 0:07 UTC (Wed)
by dann (guest, #11621)
[Link]
Here's the documentation for dabbrev-expand from the tcsh manual:
dabbrev-expand (M-/)
Posted May 12, 2006 14:31 UTC (Fri)
by dododge (guest, #2870)
[Link] (1 responses)
A potential downside to bash's programmable completion is when a
distribution has pre-loaded it with a ton of rules that override
normal completion. For example someone has preconfigured
a rule so that bash will only complete
The most interesting auto-completion system I've ever used was
The downside was that it could end up using several megabytes of RAM
to hold the predictive history, and back in those days it really hurt
for each shell to be eating 8M.
It was apparently someone's thesis project and there was even a book
published about it, but the software pretty much died sometime
in the mid-90s. You can still find old versions of the sourcecode lying
around if you look really hard, but none of the ones I've seen are
Linux-ready.
Posted May 12, 2006 16:08 UTC (Fri)
by liljencrantz (guest, #28458)
[Link]
In my experience, it is generally better to include a bit too many completions instead of a bit too few, but not by a wide margin.
Does anyone else find it extremely annoying when completion clobbers the screen with a menu? It
has taken me years to find out that bash supports cyclic tab completion with bind '"\t":menu-
complete'. I find that cyclic completion works a lot faster for me than menu-based
completion.
CLI Magic: Bash complete (Linux.com)
Very nice, thanks for the tip. It looks like there is an extra space in there (between the hyphen and the letter 'c'). It should be:CLI Magic: Bash complete (Linux.com)
The Linux.com blurb strongly implies that most other shells do not have auto complete, which is false. Tcsh, zsh and fish all support tab completion, and at least the latter two have more advanced completions in my experience.
CLI Magic: Bash complete (Linux.com)
In most distros, bash just beeps at you when you have more than one option for completion. This is unhelpful, and leads to people turning off the system bell. Much better is to have it print the options:CLI Magic: Bash complete (Linux.com)
set show-all-if-ambiguous on
I like the beep - just press tab again to get the list of all the matches.CLI Magic: Bash complete (Linux.com)
> Of course I also have directories with tens of thousands of files in them > (over NFS) and you might as well go make some coffee if you double tab in > one of those...CLI Magic: Bash complete (Linux.com)
killall mpl[TAB] -> ayer
ping lo[TAB] -> calhost
...I know I've using tab completion too much when logging in I automatically type "jha[TAB]"CLI Magic: Bash complete (Linux.com)
You really know you're in trouble when you try to tab-complete while making out a check. Of course, I personally tend more towards trying to cut-and-paste from my computer to a piece of paper or back.CLI Magic: Bash complete (Linux.com)
I have to admit to once trying to open the front door of my house with the remote keyless entry fob for my car. :-/
CLI Magic: Bash complete (Linux.com)
I'm always trying to open my house's front door with my train ticket, and do SecureID authentication with my iPod (hey, it's sort of the same shape and size, i.e., rectangularish, and smaller than a brick).CLI Magic: Bash complete (Linux.com)
Gentoo gets it right too.CLI Magic: Bash complete (Linux.com)
How so?CLI Magic: Bash complete (Linux.com)
The main type of completion missing in bash is 'dabbrev-expand'. In tcsh (and emacs) it is bound to M-/missing: dabbrev-expand
M-/ can complete the current word on the command lines with items from history. This is sometimes much faste than TAB completion if you have entered parts of the cmd line before...
That looks like Ctrl-r in Bash (search backwards in history).missing: dabbrev-expand
No, it is not, Ctrl-r implements a completely different functionalitymissing: dabbrev-expand
(and is available on all modern shells)
Expands the current word to the most recent preceding one for
which the current is a leading substring, wrapping around the his-
tory list (once) if necessary. Repeating dabbrev-expand without
any intervening typing changes to the next previous word etc.,
skipping identical matches much like history-search-backward does.
CLI Magic: Bash complete (Linux.com)
*.txt
files for the
command you're trying to run, but the file you want to use doesn't
match that pattern. I forget where I ran into this situation,
but I've seen it in action and "annoying" doesn't even begin to
describe it.
rk
, the "Reactive
Keyboard". This was an add-on that wrapped your shell session and intercepted command-line input. It was useful
with e.g. the old Sun csh because it gave you things like a browsable
history and emacs bindings. Its big trick, though, is that it could predict what you
were going to type next based on prior input. And since it was
sitting on top of the entire shell session it actually kept running
when you entered other command-line tools such as "ftp" and could
then predict your next ftp commands such as "cd pub" or "binary".
I recall it being pretty good at the predictive stuff, and very easy
to work with.
Writing completion rules is harder than you'd think. It is extremely hard to foresee all reasonable usecases for a non-trivial command. If you limit the completions too much, you'll end up with the frustration of spelling out things shat 'should' be completable, if you have too many completions, they will be worthless because there will be too much noise.CLI Magic: Bash complete (Linux.com)