如何配置的git bash命令行完成? [英] How to configure git bash command line completion?

查看:582
本文介绍了如何配置的git bash命令行完成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如。新鲜的Ubuntu的机器上,我刚刚运行 sudo易于得到的git ,而且也没有如打字完成时 git的检查[标签]

E.g. on a fresh ubuntu machine, I've just run sudo apt-get git, and there's no completion when typing e.g. git check[tab].

我没有找到 http://git-scm.com/docs 什么,但IIRC完成包括在git的包这些天,我只需要在我的.bashrc中正确项。

I didn't find anything on http://git-scm.com/docs, but IIRC completion is included in the git package these days and I just need the right entry in my bashrc.

推荐答案

在大多数发行版,混帐完成脚本安装到 /etc/bash_completion.d / 当你安装的git,没必要去github上。你只需要使用它 - 这行添加到您的的.bashrc

On Linux

on most distributions, git completion script is installed into /etc/bash_completion.d/ when you install git, no need to go to github. You just need to use it - add this line to your .bashrc:

source /etc/bash_completion.d/git

在某些Ubuntu版本,自动完成的Git默认情况下可能被打破,通过运行这个命令应该修复它重新安装:

In some versions of Ubuntu, git autocomplete may be broken by default, reinstalling by running this command should fix it:

sudo apt-get install git-core bash-completion

在Mac

您可以使用自制或MacPorts的git的安装完成。

On Mac

You can install git completion using Homebrew or MacPorts.

BREW安装的bash-完成

然后添加到您的的.bash_profile

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

的MacPorts

sudo的港口安装的git + bash_completion

然后添加到您的的.bash_profile

if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
fi

本指南中的

更多信息:猛砸安装完成的git

请注意,在所有情况下,你需要创建一个新的外壳(打开新的终端标签/窗口)更改生效。

Note that in all cases you need to create a new shell (open a new terminal tab/window) for changes to take effect.

这篇关于如何配置的git bash命令行完成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆