日期:2014-05-16 浏览次数:20928 次
本文链接:http://codingstandards.iteye.com/blog/796598 ? (转载请注明出处)
在使用bash命令行时,在提示符下,输入某个命令的前面几个字符,然后按TAB键,就会列出以这几个字符开头的命令供我们选择。不光如此,还可以进行参数补全,但只限于文件参数,当输入到参数部分时,按TAB键,就会列出以这个参数开头的文件路径供我们选择。Bash提供了一个complete内建命令,它的用途是规定参数怎么自动补全(Specify? how arguments to each name should be completed.)。它怎么使用在网上的资料都没怎么看见,man手册页不太想看,但是这个世界好人真的挺多,网站http://www.caliban.org/bash/ 提供了一个称之为bash-completion的软件包,通过一个复杂的脚本bash_completion实现可编程的补全程序,减少系统管理员日常维护工作,减少差错,提高工作效率。
?
不用管参数了,只管在输入参数时按TAB键补全了。
[root@rhel55 ~]# type -a complete
complete is a shell builtin?? <== complete是一个Bash内建命令
[root@rhel55 ~]#
[root@rhel55 ~]# cd setup/
下面用wget从
http://www.caliban.org/bash/
下载源代码的rpm包。
[root@rhel55 setup]# wget http://www.caliban.org/files/redhat/SRPMS/bash-completion-20060301-1.src.rpm
--2010-10-28 13:32:20--? http://www.caliban.org/files/redhat/SRPMS/bash-completion-20060301-1.src.rpm
正在解析主机 www.caliban.org... 83.98.221.239
Connecting to www.caliban.org|83.98.221.239|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:170596 (167K) [application/x-rpm]
Saving to: `bash-completion-20060301-1.src.rpm'
100%[==========================================================================================>] 170,596???? 91.0K/s?? in 1.8s???
2010-10-28 13:32:23 (91.0 KB/s) - `bash-completion-20060301-1.src.rpm' saved [170596/170596]
[root@rhel55 setup]# ls -l bash-completion-20060301-1.src.rpm
-rw-r--r-- 1 root root 170596 2006-03-02 bash-completion-20060301-1.src.rpm
[root@rhel55 setup]# rpmbuild --rebuild bash-completion-20060301-1.src.rpm
Installing bash-completion-20060301-1.src.rpm
warning: InstallSourcePackage: Header V3 DSA signature: NOKEY, key ID bfbaf0e8
warning: user ianmacd does not exist - using root
warning: group ianmacd does not exist - using root
warning: user ianmacd does not exist - using root
warning: group www does not exist - using root
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.75172
+ umask 022
+ cd /usr/src/redhat/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ cd /usr/src/redhat/BUILD
+ rm -rf bash_completion
+ /usr/bin/bzip2 -dc /usr/src/redhat/SOURCES/bash-completion-20060301.tar.bz2
+ tar -xvvf -
drwxrwxr-x ianmacd/ianmacd?? 0 2006-03-02 00:38:44 bash_completion/
drwxrwxr-x ianmacd/ianmacd?? 0 2006-03-01 18:45:13 bash_completion/contrib/
-rw-r--r-- ianmacd/ianmacd 748 2005-01-03 10:44:22 bash_completion/contrib/sitecopy
-rw-r--r-- ianmacd/ianmacd 261 2003-12-31 16:22:37 bash_completion/contrib/isql
-rw-r--r-- ianmacd/ianmacd 388 2002-06-13 06:03:23 bash_completion/contrib/bitkeeper
-rw-r--r-- ianmacd/ianmacd 442 2004-03-31 06:39:11 bash_completion/contrib/cksfv
-rw-r--r-- ianmacd/ianmacd 3621 2003-12-31 16:22:37 bash_completion/contrib/dsniff
-rw-r--r-- ianmacd/ianmacd 1254 2003-12-31 16:22:37 bash_completion/contrib/freeciv
-rw-r--r-- ianmacd/ianmacd? 659 2003-12-31 16:22:37 bash_completion/contrib/gkrellm
-rw-r--r-- ianmacd/ianmacd 1230 2002-08-20 00:57:44 bash_completion/contrib/gnatmake
-rw-r--r-- ianmacd/ianmacd? 258 2003-12-31 16:22:37 bash_completion/contrib/harbour
-rw-r--r-- ianmacd/ianmacd 1838 2003-12-31 16:22:37 bash_completion/contrib/larch
-rw-r--r-- ianmacd/ianmacd? 163 2003-12-31 16:22:37 bash_completion/contrib/lilypond
-rw-r--r-- ianmacd/ianmacd 1917 2003-12-31 16:22:37 bash_completion/