首页 > Linux下有的命令行工具能够「多级补全」,是如何做到的?(cmd sub-cmd options)

Linux下有的命令行工具能够「多级补全」,是如何做到的?(cmd sub-cmd options)

[描述]
有的能,有的则不能
能的: 能对sub-cmd,options,--开头的,以及其他

是如何做到的?


拿CentOS举个例子, 这里Shell用的Bash, 自动补全功能脚本存放在/etc/bash_completion.d/目录下

# ls -al /etc/bash_completion.d/
total 136
drwxr-xr-x.  2 root root  4096 Jul 21  2015 .
drwxr-xr-x. 78 root root  4096 Mar 14 15:31 ..
-rw-r--r--.  1 root root  2379 Nov 11  2010 bzr
-rwxr-xr-x   1 root root   935 Oct 16  2014 gdbus-bash-completion.sh
-rw-r--r--.  1 root root 45281 Mar  5  2013 git
-rw-r--r--.  1 root root 11481 Aug 23  2010 mercurial.sh
-rw-r--r--   1 root root 39423 May 26  2009 subversion
-rw-r--r--.  1 root root  8031 Jun 22  2012 yum-utils.bash
-rw-r--r--.  1 root root 10082 Dec 17  2013 yum.bash
【热门文章】
【热门文章】