maj prompt
This commit is contained in:
parent
d2982d2ce9
commit
7d33c68bbd
1 changed files with 8 additions and 110 deletions
|
@ -24,118 +24,16 @@ PS1_LGRIS='\[\033[37m\]'
|
||||||
PS1_ORANGE='\[\033[38;5;208m\]'
|
PS1_ORANGE='\[\033[38;5;208m\]'
|
||||||
|
|
||||||
if [ "$UID" = 0 ]; then
|
if [ "$UID" = 0 ]; then
|
||||||
USER_COLOR=$PS1_LROUGE
|
PLATEFORME=$PS1_LROUGE
|
||||||
else
|
else
|
||||||
USER_COLOR=$PS1_LVERT
|
PLATEFORME=$PS1_LVERT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PLATEFORME=$PS1_LVERT
|
function parse_git_dirty {
|
||||||
|
[[ $(git status --porcelain 2> /dev/null) ]] && echo "*"
|
||||||
__gitdir() {
|
}
|
||||||
if [ -z "${1-}" ]; then
|
function parse_git_branch {
|
||||||
if [ -n "${__git_dir-}" ]; then
|
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/ (\1$(parse_git_dirty))/"
|
||||||
echo "$__git_dir"
|
|
||||||
elif [ -d .git ]; then
|
|
||||||
echo .git
|
|
||||||
else
|
|
||||||
git rev-parse --git-dir 2>/dev/null
|
|
||||||
fi
|
|
||||||
elif [ -d "$1/.git" ]; then
|
|
||||||
echo "$1/.git"
|
|
||||||
else
|
|
||||||
echo "$1"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
__git_ps1() {
|
PS1="\n\t ${PLATEFORME}\h${PS1_NORMAL} \[\033[32m\]\w\[\033[33m\]$(parse_git_branch)\[\033[00m\] $ "
|
||||||
local g="$(__gitdir)"
|
|
||||||
if [ -n "$g" ]; then
|
|
||||||
local r
|
|
||||||
local b
|
|
||||||
if [ -f "$g/rebase-merge/interactive" ]; then
|
|
||||||
r="|REBASE-i"
|
|
||||||
b="$(cat "$g/rebase-merge/head-name")"
|
|
||||||
elif [ -d "$g/rebase-merge" ]; then
|
|
||||||
r="|REBASE-m"
|
|
||||||
b="$(cat "$g/rebase-merge/head-name")"
|
|
||||||
else
|
|
||||||
if [ -d "$g/rebase-apply" ]; then
|
|
||||||
if [ -f "$g/rebase-apply/rebasing" ]; then
|
|
||||||
r="|REBASE"
|
|
||||||
elif [ -f "$g/rebase-apply/applying" ]; then
|
|
||||||
r="|AM"
|
|
||||||
else
|
|
||||||
r="|AM/REBASE"
|
|
||||||
fi
|
|
||||||
elif [ -f "$g/MERGE_HEAD" ]; then
|
|
||||||
r="|MERGING"
|
|
||||||
elif [ -f "$g/BISECT_LOG" ]; then
|
|
||||||
r="|BISECTING"
|
|
||||||
fi
|
|
||||||
|
|
||||||
b="$(git symbolic-ref HEAD 2>/dev/null)" || {
|
|
||||||
|
|
||||||
b="$(
|
|
||||||
case "${GIT_PS1_DESCRIBE_STYLE-}" in
|
|
||||||
(contains)
|
|
||||||
git describe --contains HEAD ;;
|
|
||||||
(branch)
|
|
||||||
git describe --contains --all HEAD ;;
|
|
||||||
(describe)
|
|
||||||
git describe HEAD ;;
|
|
||||||
(* | default)
|
|
||||||
git describe --exact-match HEAD ;;
|
|
||||||
esac 2>/dev/null)" ||
|
|
||||||
|
|
||||||
b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." ||
|
|
||||||
b="unknown"
|
|
||||||
b="($b)"
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
|
|
||||||
local w
|
|
||||||
local i
|
|
||||||
local s
|
|
||||||
local u
|
|
||||||
local c
|
|
||||||
|
|
||||||
if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
|
|
||||||
if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then
|
|
||||||
c="BARE:"
|
|
||||||
else
|
|
||||||
b="GIT_DIR!"
|
|
||||||
fi
|
|
||||||
elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
|
|
||||||
if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
|
|
||||||
if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
|
|
||||||
git diff --no-ext-diff --ignore-submodules \
|
|
||||||
--quiet --exit-code || w="*"
|
|
||||||
if git rev-parse --quiet --verify HEAD >/dev/null; then
|
|
||||||
git diff-index --cached --quiet \
|
|
||||||
--ignore-submodules HEAD -- || i="+"
|
|
||||||
else
|
|
||||||
i="#"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then
|
|
||||||
git rev-parse --verify refs/stash >/dev/null 2>&1 && s="$"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then
|
|
||||||
if [ -n "$(git ls-files --others --exclude-standard)" ]; then
|
|
||||||
u="%"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${1-}" ]; then
|
|
||||||
printf "$1" "$c${b##refs/heads/}$w$i$s$u$r"
|
|
||||||
else
|
|
||||||
printf " (%s)" "$c${b##refs/heads/}$w$i$s$u$r"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
export GIT_PS1_SHOWDIRTYSTATE=1 GIT_PS1_SHOWUNTRACKEDFILES=1 GIT_PS1_SHOWSTASHSTATE=1
|
|
||||||
export PS1="${debian_chroot:+($debian_chroot)}${USER_COLOR}\u${PS1_NORMAL}@${PLATEFORME}\h${PS1_NORMAL} [${PS1_LBLEU}\w${PS1_NORMAL}]${PS1_VERT}\$(__git_ps1)${PS1_NORMAL}"' \$ '
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue