git bash 명령 줄 완성을 구성하는 방법은 무엇입니까?
예를 들어 새로운 우분투 머신에서 방금 실행 sudo apt-get git
완료가 없습니다 git check[tab]
.
http://git-scm.com/docs 에서 아무것도 찾지 못했지만 IIRC 완성은 요즘 git 패키지에 포함되어 있으며 bashrc에 올바른 항목이 필요합니다.
Linux에서
대부분의 배포판에서 자식 을 설치할 때 자식 완료 스크립트가 /etc/bash_completion.d/
(또는 /usr/share/bash-completion/completions/git
)에 설치되므로 GitHub의로 이동할 필요가 없습니다. 당신은 그것을 사용하기 만하면됩니다-이 줄을 당신의 .bashrc
:
source /etc/bash_completion.d/git
# or
source /usr/share/bash-completion/completions/git
일부 Ubuntu 버전에서는 git 자동 완성이 기본적으로 손상 될 수 있습니다.이 명령을 실행하여 다시 설치하면 문제가 해결됩니다.
sudo apt-get install git-core bash-completion
Mac에서
Homebrew 또는 MacPorts를 사용하여 git 완성을 사용할 수 있습니다.
홈브류
경우 $BASH_VERSION
> 4 : brew install bash-completion@2
(업데이트 된 버전) MacOS 기본으로 3.2.57 (1) 릴리스와 함께 제공되는 bash 버전을 특별히주의하십시오.
추가 .bash_profile
:
if [ -f /usr/local/share/bash-completion/bash_completion ]; then
. /usr/local/share/bash-completion/bash_completion
fi
이전 버전의 bash의 경우 : brew install bash-completion
추가 .bash_profile
:
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion
MacPorts
sudo port install git +bash_completion
그런 다음 추가하십시오 추가하십시오 .bash_profile
:
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
fi
이 가이드의 추가 정보 : Bash git 완료 설치
모든 경우에 변경 사항을 적용 할 새 셸 (새 터미널 탭 / 창)을 선택합니다.
나는 같은 문제가 아래 단계를 따를 것입니다.
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
그런 다음 .bash_profile
(일반적으로 홈 폴더 아래에) 다음 줄을 추가하십시오.
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
출처 : http://code-worrier.com/blog/autocomplete-git/
표시되는 대부분의 지침은 다운로드하라고 알려드립니다.
https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
bash 시작 펼쳐보기에서 .bashrc
.
하지만 .NET master
의 최신 버전 인 브랜치를 참조하기 때문에 문제 가 git-completion.bash
있습니다. 문제는 설치 한 git 버전과 설치되지 않기 때문에 가끔 고장날 수있는 것입니다.
사실, 지금은 master
브랜치에 git-completion.bash
git v2.18이 필요한 새로운 기능이 있기 때문에 당장 은 패키지 관리자와 설치 관리자가 아직 업데이트하지 않습니다. 새로운 기능이 있습니다. 오류가 발생합니다.unknown option: --list-cmds=list-mainporcelain,others,nohelpers,alias,list-complete,config
따라서 가장 안전한 해결책은 설치 한 git과 일치하는 버전 / 태그를 참조하는 것입니다. 예를 들면 :
https://raw.githubusercontent.com/git/git/v2.17.1/contrib/completion/git-completion.bash
참고 그것이 가지고 v2.17.
URL에 대신 master
. 그리고 물론 bash 시작 펼쳐야합니다.
Ubuntu 14.10
설치 git-core
하고bash-completion
sudo apt-get install -y git-core bash-completion
현재 세션 사용
source /usr/share/bash-completion/completions/git
모든 세션에 대해 항상 사용 비용
echo "source /usr/share/bash-completion/completions/git" >> ~/.bashrc
참조 https://github.com/git/git/blob/master/contrib/completion/git-completion.bash를
완료 펼치기를 제공하기 만하면됩니다.
내 우분투에는 여기에 파일이 설치되어 있습니다.
source /etc/bash_completion.d/git-prompt
링크를 따라 /usr/lib/git-core
폴더 로 실행할 수 있습니다 . 거기에서 지침, PS1 설정 또는 사용 방법을 사용할 수 있습니다.__git_ps1
누군가에게 도움이 될 수 있습니다 :-
다음 링크에서 .git-completion.bash를 다운로드 한 후,
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
__git_ps1 함수를 사용하려고하면 다음과 같은 오류가 발생했습니다.
-bash: __git_ps1: command not found
__git_ps1은 git-prompt.sh에 정의되어 있기 때문에이 명령이 작동하려면 master에서 별도로 스크립트를 다운로드해야합니다. 따라서 .git-completion.bash 다운로드와 유사하게 git-prompt.sh를 가져옵니다.
curl -L https://raw.github.com/git/git/master/contrib/completion/git-prompt.sh > ~/.bash_git
그런 다음 .bash_profile에 다음을 추가하십시오.
source ~/.bash_git
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
export PS1='\W$(__git_ps1 "[%s]")>'
fi
source ~ / .bash.git은 다운로드 한 파일을 실행하고
export PS1='\W$(__git_ps1 "[%s]")
명령은 현재 작업 디렉토리 (git 저장소 인 경우) 뒤에 체크 아웃 브랜치 이름을 추가합니다.
따라서 다음과 같이 보일 것입니다.
dir_Name[branch_name]
여기서 dir_Name은 작업 디렉토리 이름이고 branch_name은 현재 작업중인 브랜치의 이름입니다.
참고-__git_ps1은 대소 문자를 구분합니다.
다음에서 수행하십시오 ~/.bashrc
.
source /usr/share/bash-completion/completions/git
다른 답변은 설치하라고 말하고 bash-completion
있지만 그렇게 할 필요는 없지만 그렇게하면 완성을 직접 소스 할 필요가 없습니다. 둘 중 하나만 수행합니다.
보다 일반적인 솔루션은 bash-completion 프로젝트에서 권장하는대로 시스템 위치를 쿼리하는 것입니다.
source "$(pkg-config --variable=completionsdir bash-completion)"/git
우분투
여기에 아름다운 답이 있습니다 . Ubuntu 16.04에서 나를 위해 일했습니다.
윈도우
Git Bash 는 자동 완성을 허용하는 도구입니다. 이것이 표준 배포의 일부인지 확실하지 않으므로이 링크 도 유용 할 수 있습니다 . 그건 그렇고, Git Bash는 Linux 쉘 명령 을 사용하여 Windows에서 작업 할 수 있습니다. 이는 GNU / Linux 환경에 대한 경험이있는 사람들에게 좋은 일입니다.
Git 프로젝트의 Github에서 git 명령을 자동 완성하는 bash 파일을 제공합니다.
이를 홈 디렉토리에 다운로드하고 bash가 실행하도록해야합니다. 그것은 단순히 두 단계이며 다음 블로그 게시물에서 완벽하게 설명됩니다.
코드 걱정 블로그 : autocomplete-git /
나는 그것을 Mac에서 테스트했으며 다른 시스템에서도 작동합니다. 다른 운영 체제에도 동일한 접근 방식을 적용 할 수 있습니다.
참고 URL : https://stackoverflow.com/questions/12399002/how-to-configure-git-bash-command-line-completion
'IT' 카테고리의 다른 글
Apache :“AuthType이 설정되지 않은 것!” (0) | 2020.08.27 |
---|---|
메모장 ++ 다중 편집 (0) | 2020.08.27 |
printf에서 Java의 "% n"은 어떻게? (0) | 2020.08.26 |
자바 펼쳐 날짜에 대한 DateTime (0) | 2020.08.26 |
내 PowerShell 펼쳐가 실행되지 않는 이유는 무엇입니까? (0) | 2020.08.26 |