Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

If I do this:

alias g='git'

I loose all completion rules (i.e. branches and remotes are no longer being automatically completed when I hit TAB after typing, for example g push o).

share|improve this question
    
While I don't have an answer for you, I'm going to have to take a minute and wonder if not typing those two other letters is really giving you much of an advantage? –  Marco Ceppi Sep 19 '11 at 13:17
2  
Sure it does! I'm typing 'g' probably over a 100 times a day. –  Paweł Gościcki Sep 19 '11 at 13:29
2  
Aliasing often-used short commands to even shorter aliases saves me hundreds of keypresses a day. According to my shell history, I have used the alias g=git 756 times in the past month, meaning I saved pressing the 'g' and 'i' keys 1512 times total. That, combined with my git aliases, probably saves me tens of thousands of key presses a month. –  paraxor Dec 12 '12 at 1:56

2 Answers 2

up vote 8 down vote accepted

Copying and modifying opportunely from /etc/bash_completion.d/git, add the following lines to your ~/.bashrc:

complete -o bashdefault -o default -o nospace -F _git g 2>/dev/null \
    || complete -o default -o nospace -F _git g
share|improve this answer
    
Ha! Wunderbar! Works just like it should :) –  Paweł Gościcki Sep 19 '11 at 13:32
    
I also had to add source /usr/share/bash-completion/completions/git to my .bashrc –  pcx 3 hours ago

The updated way to do this (complete wouldn't work for me):

  1. cd - switch to your home directory
  2. wget https://raw.github.com/git/git/master/contrib/completion/git-completion.bash
  3. Add source ~/git-completion.bash to your .bashrc file (if you don't have this file make one in your home folder, bash will look for it automatically)
  4. Add alias g='git'to your .bashrc file.
  5. Start a new session or source your changes with source ~/.bashrc
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.