Wednesday, February 3, 2010

Fedora's bash shell completion

Once upon a time you had to dig around in /usr/share/doc/bash-version/ to get some idea of how to get tabbed completions of options working on your Fedora-based system. A few examples showed how to get it going.

Now there's a package for it:-


Installed Packages
Name : bash-completion
Arch : noarch
Epoch : 1
Version : 1.1
Release : 4.fc12
Size : 453 k
Repo : installed
From repo : updates
Summary : Programmable completion for Bash
URL : http://bash-completion.alioth.debian.org/
License : GPLv2+
Description: bash-completion is a collection of shell functions that take advantage
: of the programmable completion feature of bash 2.


A few handy tool, especially for those programs that have a lot of command-line switches. rsync, (see if it's installed on your system with `which rsync`), is one such example.

Once installed you use the bash completion package like this.


command --[tab][tab]


or

command --letter[tab]


example listed here


rsync --verbose --dry-run --
--address= --compress --devices --ignore-errors --no-blocking-io --port= --size-only --version
--archive --config= --dry-run --ignore-existing --no-detach --progress --sparse --whole-file
--backup --copy-links --exclude= --ignore-times --no-whole-file --quiet --stats --write-batch=
--backup-dir --copy-unsafe-links --exclude-from= --include= --numeric-ids --read-batch= --suffix=
--blocking-io --cvs-exclude --existing --include-from= --one-file-system --recursive --temp-dir=
--block-size= --daemon --force --links --owner --relative --timeout=
--bwlimit= --delete --group --log-format= --partial --rsh= --times
--checksum --delete-after --hard-links --max-delete= --password-file= --rsync-path= --update
--compare-dest= --delete-excluded --help --modify-window= --perms --safe-links --verbose


So I can quickly see the options available without looking up the man page.

No comments:

Post a Comment