Penguin
Blame: TabCompletion
EditPageHistoryDiffInfoLikePages
Annotated edit history of TabCompletion version 2, including all changes. View license author blame.
Rev Author # Line
2 JohnMcPherson 1 A time-saving tool is known as command completion, currently known as Tab Completion. If you type part of a file, command, or pathname and then press the ~[Tab] key, bash(1) will present you with either the remaining portion of the file/path, or a beep (if sound is enabled on your system). If you get a beep, just press ~[Tab] again to obtain a list of the files/paths that match what has been typed so far.
1 CraigBox 2
2 JohnMcPherson 3 For example, if you forget the command updatedb, but remember a portion of the command, you can su to root, then at the shell prompt, type up, press the ~[Tab] key twice and you will see a list of possible completions, including updatedb and uptime. By typing the partial command "upd" and pressing ~[Tab] again, your command is completed for you.
1 CraigBox 4
2 JohnMcPherson 5 !!bash(1)
6 You may need to <tt>source /etc/bash_completion</tt> before you get extra programmable completion features, if your system doesn't already source this for interactive shells.
7
8 !!zsh(1)
9 Zsh has a more powerful tab-completion mechanism than bash. This comes at the cost of slightly more processing and bloat, although these days you won't notice. To get the advanced shell function-based completion, you need to run the <tt>compinstall</tt> function once (which will set up your .zshrc file for future use).
10
11 Examples include:
12 <verbatim>
13 $ ls -l
14 total 1
15 -rw-r--r-- 1 me me 0 Jul 29 09:45 file1
16 -rwxr-xr-x 1 me me 0 Jul 29 09:45 file2*
17 $ chmod -x [TAB]
18 </verbatim>
19 completing to only those files that currently have the +x permission set -- in this case, <tt>file2</tt>.
20
21 <verbatim>
22 $ tar [TAB]
23 A -- append to an archive
24 c -- create a new archive
25 f -- specify archive file or device
26 t -- list archive contents
27 u -- update archive
28 v -- verbose output
29 x -- extract files from an archive
30 </verbatim>
31 tells you all the available options for this command (and what they do), based on any options you have already added. For <tt>tar</tt>, it will only complete files ending in ".gz" or ".bz2" if the <tt>-z</tt> or <tt>-j</tt> option is given, respectively.
32
33 See the zshcompsys ManPage for details on customising the completion rules.
34
35 ----
36 You can enable limited tab-completion on Windows 2000 - see WindowsNotes.