Git Completion.bash

Автор:

Download and place git-flow-completion.bash in home directory (/ in msysgit shell) Add a.bashrc file to your home directory with the following line (or add this line to existing.bashrc file): source /git-flow-completion.bash. Git in Bash If you’re a Bash user, you can tap into some of your shell’s features to make your experience with Git a lot friendlier. Git actually ships with plugins for several shells, but it’s not turned on by default. First, you need to get a copy of the contrib/completion/git-completion.bash file out of the Git source code.

Bash (Bourne Again Shell) is undoubtedly the most popular Linux shell out there, no wonder it is the default shell on many Linux distributions. One of its most charming features is the built-in “auto-completion” support.

Sometimes referred to as TAB completion, this feature permits you to easily complete a command structure. It allows typing a partial command, then pressing the [Tab] key to auto-complete the command and it arguments. It lists all multiple completions, where possible.

Just like Bash, nearly all modern Linux shells ship in with command completion support. In this short guide, we will show you how to turn on the Bash auto-completion feature in CentOS and RHEL systems.

To make working on the command line super easy for you, this is one of the many things you ought to do while performing:

First, you need to enable the EPEL repository on your system, then install the bash-completion package plus some extras using YUM package manager, like this.

Now that you have installed bash completion, you should enable it to start working. First source the bash_completion.sh file. You can use the locate command below to find it:

Alternatively, logout of your current login current session and re-login.

Iromusic for mac pro. Now the auto-completion feature should be working on your system, you can try it out as shown below.

Check Bash Auto-Completion

Note: TAB completion works for path names and variables names as well, and it is programmable.

That’s all! In this guide, we showed how to install and enable the Bash auto-completion feature, also known as TAB completion in CentOS/RHEL. You can ask any questions via the comment section below.

I installed git using on my new Snow Leopard installation. After MacPorts is installed from the.dmg image, these would be the commands in Terminal.app: sudo port selfupdatesudo port install git-core +bashcompletionIf you also want support for pulling from SVN repositories and docs, use this instead of the second line: sudo port install git-core +bashcompletion +doc +svnThen add the following to your /.profile or /.bashprofile: # MacPorts Bash shell command completionif -f /opt/local/etc/bashcompletion ; then.

/opt/local/etc/bashcompletionfior for MacPorts since version 2.1.2 on Mountain Lion: # MacPorts Bash shell command completionif -f /opt/local/etc/profile.d/bashcompletion.sh ; then. /opt/local/etc/profile.d/bashcompletion.shfior for MacPorts with newer versions of git: if -f /opt/local/share/git-core/git-prompt.sh ; then. /opt/local/share/git-core/git-prompt.shfiNote: bash 4.1 or higher is required by bashcompletion.sh. If completion doesn't work try echo $BASHVERSION to see if that's the issue.

If so, enter MacPorts bash by typing bash and try git completion again. Because /opt/local/etc/profile.d/bashcompletion.sh needs $BASHVERSION 4.1 or better, I had to do the following on a Mac OS X 10.8.3 with MacPorts 2.1.3: Switch the Mac OS X login shell from its default /bin/bash (3.2.48(1)-release) to MacPorts /opt/local/bin/bash (4.2.42(2)-release) like its described here: stackoverflow.com/a/784.

Basically if `grep /opt/local/bin/bash /etc/shells` ; then echo /opt/local/bin/bash chsh -s /opt/local/bin/bash; else echo /opt/local/bin/bash sudo tee -a /etc/shells; chsh -s /opt/local/bin/bash; fi–Mar 15 '13 at 21:25. If you installed git using homebrew than you might adjust the MacPorts advice a little and add this to your.bashprofile and.bashrc if -f `brew -prefix`/etc/bashcompletion.d/git-completion.bash ; then.

`brew -prefix`/etc/bashcompletion.d/git-completion.bashfiThe best way to check if you have git correctly installed using homebrew ist to execute brew info gitand check the output for the install directory of the git bash completionLatest version of Git (1.7.12) also requires the following to enable the prompt. If -f `brew -prefix`/etc/bashcompletion.d/git-prompt.sh ; then. `brew -prefix`/etc/bashcompletion.d/git-prompt.shfi. All you need to do is place the git-completion.bash file in your user home bin directory and place the following in you.profile or.bashprofile file: export PATH='$HOME/bin:$PATH'source /bin/git-completion.bashPS1='u@h w$(gitps1 ' (%s)')$ 'What this does is make sure that your local bin is in the PATH and the source command gets things going. Then of course the PS1 change puts the currently checked out branch in the prompt.So, no MacPort install to then install a the 'completion' version of GIT (especially irritating if you already have it installed). Annoyingly this has been broken yet again. This time its the git folks with version 1.7.12-1.

To allow people to have just the prompt functionality without the completion functionality (which can slows things down), they refactored the prompt functionality out of bashcompletion/git and into its own file git-prompt.sh.So adding bashcompletion as described by @Lara will only get you completion (hitting tab completes tag/branch names).To get the gitps1 so you can use it in your PS1 prompt you also need to add the following to your /.profile. /opt/local/share/doc/git-core/contrib/completion/git-prompt.shSome background is here.

I use brew, so a master bashcompletion script which runs all the ones in bashcompletion.d seems not to be provided. The solutions which propose just running a single script to add git completions aren't extensible, because different packages will add different completion scripts, and you probably want to run them all. Therefore I added this (adapted from Arch Linux) to the end of /etc/bashrc: # source compat completion directory definitionsBASHCOMPLETIONCOMPATDIR=/usr/local/etc/bashcompletion.dif -d $BASHCOMPLETIONCOMPATDIR && -r $BASHCOMPLETIONCOMPATDIR && -x $BASHCOMPLETIONCOMPATDIR ; thenfor i in $(LCALL=C command ls '$BASHCOMPLETIONCOMPATDIR'); doi=$BASHCOMPLETIONCOMPATDIR/$i -f $i && -r $i &&.