Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set up autocompletion for Git commands?

I have Git (version 1.7.2.5) bash compeletion working on my Debian squeeze (6.0). Git was installed with aptitude and I am using standard debian's bash, which supports command line autocompletion.

Now, I just installed Git (1.5.6.5) on an other machine (Lenny/Debian 5.0) and the there is no autocompletion.

  1. Why is Git autocomplete not working on the second machine? How do I diagnose this?

  2. What is making completion work on my machine? I have looked for the file git-completion.bash but it doesn't seem to be on my machine. How does Git complete ever work?

  3. How can I bring git complete to the other machine?

like image 462
redochka Avatar asked Jun 23 '12 22:06

redochka


People also ask

What tool do I need to install to make my terminal show the autocompletion of the command that I'm writing?

3 Answers. Kali uses zsh instead of bash as the default shell and the feature you are referring to is called autosuggestions.

How do I use autocomplete in CMD?

Using autocomplete is as simple as pressing the [TAB] and the active command line options will fill-in. If more than one option is available, you can hit [TAB] twice to display all possible choices and continue typing until there is only one matching choice left.


2 Answers

You need to source /etc/bash_completion.d/git to enable git auto-completion.

In my .bashrc it's done with:

for file in /etc/bash_completion.d/* ; do     source "$file" done 
like image 142
Piotr Praszmo Avatar answered Sep 19 '22 03:09

Piotr Praszmo


Put the following lines in your ~/.bashrc

if [ -f /etc/bash_completion ]; then     . /etc/bash_completion fi 

The script/program /etc/bash_completion already includes the scripts in /etc/bash_completion.d and also defines some functions needed by the included scripts.

like image 21
Rudger Avatar answered Sep 22 '22 03:09

Rudger