Mac system implementation of git command auto-completion

Source: Internet
Author: User

When I first use Mac computer, because I am engaged in software development programmer, so must often use to git, and then found that in Max, git can not implement the command of automatic completion, and then find the data on the Internet, finally found the solution, finally can realize the automatic completion of the GIT command function, Now share the following.

Installing homebrew

Install the Configuration homebrew First (note: If it has already been installed, skip):

Homebrew's website: https://brew.sh/index_zh-cn.html

Enter the following command at the terminal:

/usr/bin/ruby-e "$ (curl-fssl https://raw.githubusercontent.com/Homebrew/install/master/install)"

Then will start the installation, the middle will prompt to enter the system user's password, after the installation succeeds will have the following prompt:

At this point you can enter the command at the command line brew to test, you can see the following results, indicating that the installation was successful.

Formally start one, install Bash-completion

Bash-completion If you have followed, skip the steps

$ brew Install bash-completion### after the installation is complete, review the BREW Info bash-completion### will output similar to the following ==>~/. Bash_profile:  if [-F $ (brew--prefix)/etc/bash_completion    ];then--prefix)/etc/Bash_ Completion  fihomebrew's own bash completion script have been installed to  /usr/local/etc/bash_ COMPLETION.D

Will If...then ... That sentence added to ~/.bash_profile (if there is no file, create a new one)

Restart the terminal, the above is the installation Bash-completion section.

Second, copy files, set the path

Visit the following Web site

Https://github.com/git/git.git

Locate the Git-completion.bash in the "contrib/completion/" directory, then click Edit, copy its contents, copy it to a text file, and save it as a Git-completion.bash file.
Then copy the file to the ~/directory with the command.

$ CP Xxx/git-completion.bash ~/.git-completion.bash

XXX is the directory where the file is located, note that the file name after the copy is. Git-completion.bash

Add the following in the ~/.BASHRC file (if not in this directory, create a new one):

source ~/.git-completion.bash
Third, start: terminal input
$ source ~/.git-completion.bas

Note: If you don't enter it, it won't work.

Add the following sentence to the ~/.bash_profile

if [-F ~/.git-completion.bash]; Then   . ~/.git-completion.bashfi

Do not add want to complete the function, each time need to execute
SOURCE ~/.git-completion.bash
Completion to take effect

Note: Original address: http://blog.csdn.net/chenbifeng/article/details/51570606

Mac system implementation of git command auto-completion

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.