Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/.bashrc b/.bashrc
- index 02a3faa..e9ab47a 100644
- --- a/prompt
- +++ b/prompt
- @@ -35,7 +35,7 @@ PS1_GIT_BIN=$(which git 2>/dev/null)
- function prompt_command {
- local PS1_GIT=
- local PS1_VENV=
- - local GIT_BRANCH=
- + local CURRENT_GIT_BRANCH=
- local GIT_DIRTY=
- local PWDNAME=$PWD
- local VIRTUAL_ENV=${VIRTUAL_ENV-}
- @@ -56,9 +56,9 @@ function prompt_command {
- # 'git repo for dotfiles' fix: show git status only in home dir and other git repos
- if [[ "${CUR_DIR}" != "${HOME}" ]] || [[ "${PWD}" == "${HOME}" ]]; then
- # get git branch
- - GIT_BRANCH=$($PS1_GIT_BIN symbolic-ref HEAD 2>/dev/null)
- - if [[ ! -z $GIT_BRANCH ]]; then
- - GIT_BRANCH=${GIT_BRANCH#refs/heads/}
- + CURRENT_GIT_BRANCH=$($PS1_GIT_BIN symbolic-ref HEAD 2>/dev/null)
- + if [[ ! -z $CURRENT_GIT_BRANCH ]]; then
- + CURRENT_GIT_BRANCH=${CURRENT_GIT_BRANCH#refs/heads/}
- # get git status
- local GIT_STATUS=$($PS1_GIT_BIN status --porcelain 2>/dev/null)
- @@ -69,7 +69,7 @@ function prompt_command {
- fi
- # build b/w prompt for git and virtual env
- - [[ ! -z $GIT_BRANCH ]] && PS1_GIT=" (git: ${GIT_BRANCH})"
- + [[ ! -z $CURRENT_GIT_BRANCH ]] && PS1_GIT=" (git: ${CURRENT_GIT_BRANCH})"
- [[ ! -z $VIRTUAL_ENV ]] && PS1_VENV=" (venv: ${VIRTUAL_ENV#$WORKON_HOME})"
- # calculate prompt length
- @@ -90,11 +90,11 @@ function prompt_command {
- if $color_is_on; then
- # build git status for prompt
- - if [[ ! -z $GIT_BRANCH ]]; then
- + if [[ ! -z $CURRENT_GIT_BRANCH ]]; then
- if [[ -z $GIT_DIRTY ]]; then
- - PS1_GIT=" (git: ${color_green}${GIT_BRANCH}${color_off})"
- + PS1_GIT=" (git: ${color_green}${CURRENT_GIT_BRANCH}${color_off})"
- else
- - PS1_GIT=" (git: ${color_red}${GIT_BRANCH}${color_off})"
- + PS1_GIT=" (git: ${color_red}${CURRENT_GIT_BRANCH}${color_off})"
- fi
- fi
- @@ -123,9 +123,21 @@ function prompt_command {
- # set title
- echo -ne "\033]0;${USER}@${HOSTNAME}:${PWDNAME}"; echo -ne "\007"
- +
- + if [ -n "$CURRENT_GIT_BRANCH" ]; then
- + GIT_BRANCH="$CURRENT_GIT_BRANCH";
- + else
- + unset GIT_BRANCH
- + fi
- + export GIT_BRANCH
- + GIT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || true)"
- + if [ -z "$GIT_ROOT" ]; then
- + unset GIT_ROOT
- + fi
- + export GIT_ROOT
- }
- # set prompt command (title update and color prompt)
- PROMPT_COMMAND=prompt_command
- # set new b/w prompt (will be overwritten in 'prompt_command' later for color prompt)
- -PS1='\u@\h:\w\$ '
- +PS1='\u@\h:\w\$ '
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement