Centos 6.6命令列實現自動補全

來源:互聯網
上載者:User

標籤:linux   centos   自動補全   

公司同事用的ubuntu系統,自動補全功能不錯,但是本人的Centos 6.6系統使用sudo的時候就不能自動補全了,git命令也不能自動補全。

網上搜尋一番解決方案如下。

一  git不能補全問題

下載git源碼 

$ git clone https://www.kernel.org/pub/scm/git/
找到git-completion.bash檔案拷貝到 ~/目錄下

$ sudo cp contrib/completion/git-completion.bash ~/.git-completion.bash
編輯 /etc/bashrc 檔案  在最後加入:source /home/yourname/.git-completion.bash

或者

$ sudo cp contrib/completion/git-completion.bash /etc/bash_completion.d/
source /etc/bash_completion.d/git-completion.bash

得到git-completion.bash的另一種方法:

sudo find / -name 'git-completion*'/usr/share/doc/git-1.7.1/contrib/completion/git-completion.bash
所以linux系統裡面是有一份檔案的,直接拷貝就可以了。


二  自動補全。這裡說的補全,不只是系統預設的補全路徑跟檔案名稱的補全功能,而是命令的參數的補全,有了這個補全之後,在Bash裡面幾乎能補全任何可以補全的補全。

RedHat系的預設沒有安裝,需要安裝一個bash-completion,就可以實現了。當你sudo  yum  install xxx的時候,這些單詞中的任何一個你都補全,輸入到yum ins然後按Tab鍵的時候再按Tab就可以補全install。

安裝之前,在/etc/bash_completion.d/目錄下執行ls:

git                          rpmlintcreaterepo.bash           gvfs-bash-completion.sh      scl.bashdbus-bash-completion.sh   perf                         subversiondkms                      pk-completion.bash           yum.bashgdbus-bash-completion.sh  rpmdevtools.bash-completion  yum-utils.bash

安裝:
sudo yum install bash-completion

在查看/etc/bash_completion.d/下面的檔案:

ant                       gvfs-bash-completion.sh  rcsautoconf                  gzip                     redefine_filedirautomake                  iconv                    rfkillbash-builtins             ifupdown                 rpcdebugbind-utils                info                     rpmbrctl                     iproute2                 rpmdevtools.bash-completionbumblebee                 iptables                 rpmlintbzip2                     java                     rsyncchkconfig                 lsof                     sambaconfigure                 lvm                      scl.bashcoreutils                 lzma                     servicecpan2dist                 make                     shcpio                      man                      shadowcreaterepo.bash           mdadm                    smartctlcrontab                   minicom                  sqlite3cryptsetup                module-init-tools        sshcups                      mysqladmin               stracecvs                       net-tools                subversiondbus-bash-completion.sh   nmap                     tardd                        ntpdate                  tcpdumpdhclient                  open-iscsi               util-linuxdkms                      openssl                  wireless-toolsdvd+rw-tools              perf                     wodime2fsprogs                 perl                     wvdialfindutils                 pk-completion.bash       xmllintfuse                      pkg-config               xmlwfgcc                       pm-utils                 xorg-x11-server-utilsgdb                       postfix                  xsltprocgdbus-bash-completion.sh  postgresql               xzgenisoimage               procps                   yp-toolsgetent                    python                   yum.bashgit                       qdbus                    yum-utils.bashgpg2                      quota-tools

這時候就可以實現自動補全功能了。




Centos 6.6命令列實現自動補全

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.