Last active
December 6, 2016 22:36
-
-
Save ravikiranj/e74f7c4bf6d3ab14366fc671480fd199 to your computer and use it in GitHub Desktop.
mercurial bash prompt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mercurial | |
__hg_ps1 () { | |
local HG_PROMPT=$(hg prompt "{branch}:{status}:{update}:{count}:{node|short}" 2>/dev/null) | |
local HG_ARRAY=() | |
local PRINTF_FORMAT="$1" | |
if [ ! -z "$HG_PROMPT" ]; then | |
IFS=':' read -ra HG_OPTIONS <<< "$HG_PROMPT" | |
for HG_OPTION in "${HG_OPTIONS[@]}"; do | |
if [[ "$HG_OPTION" != "" ]]; then | |
HG_ARRAY+=($HG_OPTION) | |
fi | |
done | |
local FINAL_HG_PROMPT=$(IFS=: ; echo "${HG_ARRAY[*]}") | |
printf -- "$PRINTF_FORMAT" "$FINAL_HG_PROMPT" | |
fi | |
} | |
export PS1='[\u@\h \W$(__git_ps1 " \[\e[0;36m\](%s)\[\e[0m\]")$(__hg_ps1 " \[\e[0;36m\](%s)\[\e[0m\]")]# ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment