Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stujo/9811348 to your computer and use it in GitHub Desktop.
Save stujo/9811348 to your computer and use it in GitHub Desktop.
Mac OSX Terminal Tab with Git Completion
if [[ -n "$GIT_SHELL_DIR" && ! -d $GIT_SHELL_DIR ]]; then
mkdir $GIT_SHELL_DIR
curl -o $GIT_SHELL_DIR/git-completion.bash https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
chmod +x $GIT_SHELL_DIR/git-completion.bash
curl -o $GIT_SHELL_DIR/git-prompt.sh https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh
chmod +x $GIT_SHELL_DIR/git-prompt.sh
cat <<EOF >$GIT_SHELL_DIR/gitshell.sh
#!/bin/bash
source $GIT_SHELL_DIR/git-prompt.sh
source $GIT_SHELL_DIR/git-completion.bash
echo Adding Git Tab Completion and Prompt
EOF
echo 'PS1='"'"'[\u:\w$(__git_ps1 " (%s)")]\$ '"'" >> $GIT_SHELL_DIR/gitshell.sh
chmod +x $GIT_SHELL_DIR/gitshell.sh
echo "Git Shell Prompts set up source $GIT_SHELL_DIR/gitshell.sh in your ~/.bash_profile or terminal to enable it"
else
echo GIT_SHELL_DIR=$GIT_SHELL_DIR either exists or was not specified
fi
#Git Shell Setup FOR BASH ONLY
Add Tab completion for GIT and the current branch to your terminal prompt
This Process Installs these awesome scripts on a Mac OSX:
https://github.com/git/git/tree/master/contrib/completion
##Installation:
1. Type
export GIT_SHELL_DIR=~/.sej-git-shell
2. Then run this command (to download gitshell-setup.sh and run it)
curl https://gist.githubusercontent.com/stujo/9811348/raw/a73be55c70c8511b0fd6c48fb43af20e629ceb0c/gitshell-setup.sh | sh
3. Open your ~/.bash_profile file and add this line:
source ~/.sej-git-shell/gitshell.sh
4. Open a new terminal window
5. Navigate to a local git repository
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment