このソフトウェアをインストールする最も簡単な方法はRed Hat LinuxのRPMや Debian/GNU Linuxの.debパッケージを利用することです.
それらのパッケージを利用しない場合, bash_completionファイルをシステム のどこかに置いて, /tec/bashrcか~/.bashrcで読みこみます.
具体的には, たとえば/etc/bashrcに次のように書くとよいでしょう:
bash=${BASH_VERSION%.*}; bmajor=${bash%.*}; bminor=${bash#*.} if [ "$PS1" ] && [ $bmajor -eq 2 ] && [ $bminor '>' 04 ] \ && [ -f /etc/bash_completion ]; then # interactive shell # Source completion code . /etc/bash_completion fi unset bash bmajor bminorこのコードはbashのバージョンが2.04以降であるかどうかをチェックした上で, bash補完コードを読み込みます.
一目見ると大仰のように見えるかもしれませんが, このコードはbash 1.xでも 通ります. 1.xと2.xが混在するシステムでも正常に作動するのが利点です.
もしシステムに/etc/profile.dディレクトリが存在するならば, そのディレク トリにbash_completion.shというスクリプトを追加することも可能です. この コードを追加しておくことで, 次のようにすることができます:
# check for bash [ -z "$BASH_VERSION" ] && returnこの場合, /etc/profile.dにあるすべての*.shがBourne系 シェルにおいて/etc/bashrcで読み込まれます. よって他の(bash以外の)シェ ルが混在するシステムでは注意が必要です.
MacOS Xを使っている場合, /etc/bashrcは読みこまれません. この場合, bash_completionファイルを/sw/etcに置き, 以下のコードを~/.bash_profile に書きます:
if [ -f /sw/etc/bash_completion ]; then . /sw/etc/bash_completion fi/etc/bash_completion以外の場所に置いた場合, bashに読み込む前に $BASH_COMPLETIONを直しておきましょう. ~/.bashrcで設定するのがいいでしょ う.
If you get errors about 'complete' or 'compgen' not accepting the -g flag, you are probably running bash 2.05 and should either apply the group completion patch, download a prepatched bash binary of 2.05, or upgrade to 2.05a or later.
If you find that some commands, such as 'cd /usr
If you get errors about 'complete' not accepting the -o flag, you are probably running bash 2.04. In this case, you should upgrade to bash
2.05a or later. However, I have endeavoured to make the code detect this version of bash and work around this issue, so please inform me if you still encounter this error.
Copies of the patches and prepatched versions of bash are available from:
If you find that a given function is producing errors under certain circumstances when you attempt completion, try running 'set -v' or 'set -x' prior to attempting the completion again. This will produce useful debugging output that will aid me in fixing the problem if you are unable to do so yourself. Turn off the trace output by running either 'set +v' or 'set +x'.
Put it in the directory pointed to by $BASH_COMPLETION_DIR, which is defined at the beginning of the main completion script. Any scripts placed in this directory will be sourced by interactive bash shells.
<\nowiki>
Running ./configure --help lists these descriptions, but everything
after the '=' is stripped when returning completions, so I don't
know what kind of data is expected as a given option's parameter.
Is there a way of getting ./configure completion to return the
entire option string, so that I can see what kind of data is
required and then simply delete the descriptive text and add my own
data?
tar tzvf foo.tar.gz <Tab>the pathnames contained in the tar file are not displayed correctly. The slashes are removed and everything looks like it's in a single directory. Why is this?
Because the paths returned from within the tar file are likely not existing paths on the file system, '-o dirnames' must be passed to the complete built-in to make it treat them as such. However, then bash will append a space when completing on directories during pathname completion to the tar files themselves.
It's more important to have proper completion of paths to tar files than it is to have completion for their contents, so this sacrifice was made and '-o filenames' is used with complete instead.
If you would rather have correct path completion for tar file contents, define $COMP_TAR_INTERNAL_PATHS before sourcing bash_completion.
In bash 2.05b and later, you can get the pre-2.05a behaviour back by putting 'set mark-symlinked-directories on' in your /etc/inputrc or ~/.inputrc file.
$ export PATH=/bin:/sbin:/usr<Tab>Without the special treatment of the colon, the above wouldn't work without programmable completion, so it has long been a feature of the shell.
Unfortunately, you don't want the colon to be treated as a special case when doing something like:
$ man File::B<Tab>Here, the colons make bash think that it's completing the a new token that begins with 'B'.
Unfortunately, there's no way to turn this off. The only thing you can do is escape the colons with a backslash.
CVS: http://cvs.mandrakesoft.com/cgi-bin/cvsweb.cgi/soft/urpmi/ Web: http://urpmi.org/
You can make this faster by pregenerating the list of installed packages on the system. Make sure you have a readable file called /var/log/rpmpkgs. It's generated by /etc/cron.daily/rpm on modern Red Hat and Mandrake Linux systems.
If you don't have such a cron job, make one:
#!/bin/sh rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}.rpm\n' 2>&1 \ | sort > /var/log/rpmpkgsrpm completion will use this flat text file instead of the RPM database, unless it detects that the database has changed since the file was created, in which case it will still use the database to ensure accuracy.