Skip to content

Instantly share code, notes, and snippets.

@tdd
Last active April 17, 2024 10:04
Show Gist options
  • Star 28 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save tdd/473838 to your computer and use it in GitHub Desktop.
Save tdd/473838 to your computer and use it in GitHub Desktop.
Config Bash pour un prompt Git de tueur
# STEP 1: ENSURE COMPLETION AND PROMPT FUNCTION ARE LOADED
# ========================================================
# OPTION 1: If on OSX using Homebrew:
#
# source $(brew --prefix)/etc/bash_completion.d/git-prompt.sh
# source $(brew --prefix)/etc/bash_completion.d/git-completion.bash
# OPTION 2: If on OSX using built-in Git (also works on ZSH):
#
# source /usr/local/git/contrib/completion/git-prompt.sh
# source /usr/local/git/contrib/completion/git-completion.bash
# OPTION 3: If on Ubuntu/Debian/Mint using standard packages, or on Windows: pre-loaded!
# STEP 2: CONFIGURE THE PROMPT
# ============================
# Configure `__git_ps1` to tell us as much as possible
export GIT_PS1_SHOWDIRTYSTATE=1 GIT_PS1_SHOWSTASHSTATE=1 GIT_PS1_SHOWUNTRACKEDFILES=1
export GIT_PS1_SHOWUPSTREAM=verbose GIT_PS1_DESCRIBE_STYLE=branch GIT_PS1_SHOWCOLORHINTS=1
export GIT_PS1_HIDE_IF_PWD_IGNORED=1
# Colorful prompt for Bash!
export PS1='\[\e[0;36m\][\A] \u@\h:\[\e[0m\e[0;32m\]\W\[\e[1;33m\]$(__git_ps1 " (%s)")\[\e[0;37m\] \$\[\e[0m\] '
# Or if you want the basic prompt, no colors, no timestamps, just regular + Git info:
# export PS1='\u@\h:\W$(__git_ps1 " (%s)")\$ '
# Unrelated but useful: avoid auto-édit on successful merges, starting with Git 2.0
export GIT_MERGE_AUTOEDIT=no
@remitbri
Copy link

Si on a installé git avec Homebrew et que l'on veut lancer git-completion.bash et git-prompt.sh, on peut écrire

source `brew --prefix`/etc/bash_completion.d/git-completion.bash
source `brew --prefix`/etc/bash_completion.d/git-prompt.sh

pour expliciter les choses, même si ça revient dans la plupart des configurations à

source /usr/local/etc/bash_completion.d/git-completion.bash
source /usr/local/etc/bash_completion.d/git-prompt.sh

Viser une version en particulier est problématique après upgrade et cleanup…

@optyler
Copy link

optyler commented Jul 2, 2015

Sympa le prompt. Je pique!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment