Why doesn't git ls-files appear when tab stops?

I recently found a team

git ls-files 

and I find it very useful (see it with the -h option). Why doesn't it appear if I type git and then press Tab ?

I mean - where's the list of "other" git commands?

+6
source share
3 answers

git ls-files is a plumbing team, and many of these commands are β€œhidden” and fair. Over time, many have been added to the completion of bash, but many are still "hidden"

+2
source

Take a look at the ~/.git-completion.sh and __git_list_porcelain_commands() functions. The commands that git supports but will not be populated are listed there. Most of these commands are so-called "plumbing" commands, including ls-files . You can easily make them filled with tabs by commenting on the corresponding line. Like this:

 #ls-files) : plumbing;; #ls-remote) : plumbing;; #ls-tree) : plumbing;; 
+4
source

When installed by default, only the names of commands that appear in /bin , /usr/bin , etc. are displayed at the end of the tab. The file /usr/bin/git ls-files missing.

ls-files is a helper command that you will need to train your shell. Assuming you are using bash, you can run help complete to find out which commands you can put in your .bashrc .

If your distribution provides a bash -completion package, you can install it to save a lot of time:

 apt-get install bash-completion # on Debian/Ubuntu/etc. yum install bash-completion # on Fedora/Red Hat/etc. 

But as manojlds points out, this will not work for less used git commands such as ls-files , because bash -completion hides them from you. You will need to edit /etc/bash_completion.d/git to change this.

0
source

Source: https://habr.com/ru/post/911720/


All Articles