Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean barbuk theme #1766

Merged
merged 5 commits into from
Jan 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clean_files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ lint_clean_files.sh
#
themes/90210
themes/powerline
themes/barbuk

# plugins
#
Expand Down
106 changes: 53 additions & 53 deletions themes/barbuk/barbuk.theme.bash
Original file line number Diff line number Diff line change
Expand Up @@ -41,71 +41,71 @@ SCM_THEME_CURRENT_USER_PREFFIX='  '
SCM_GIT_SHOW_CURRENT_USER=false

function _git-uptream-remote-logo {
[[ "$(_git-upstream)" == "" ]] && SCM_GIT_CHAR="$SCM_GIT_CHAR_DEFAULT"
[[ "$(_git-upstream)" == "" ]] && SCM_GIT_CHAR="$SCM_GIT_CHAR_DEFAULT"

local remote remote_domain
remote=$(_git-upstream-remote)
remote_domain=$(git config --get remote."$remote".url | awk -F'[@:.]' '{print $2}')
local remote remote_domain
remote=$(_git-upstream-remote)
remote_domain=$(git config --get remote."$remote".url | awk -F'[@:.]' '{print $2}')

# remove // suffix for https:// url
remote_domain=${remote_domain//\//}
# remove // suffix for https:// url
remote_domain=${remote_domain//\//}

case $remote_domain in
github ) SCM_GIT_CHAR="$SCM_GIT_CHAR_GITHUB";;
gitlab ) SCM_GIT_CHAR="$SCM_GIT_CHAR_GITLAB";;
bitbucket ) SCM_GIT_CHAR="$SCM_GIT_CHAR_BITBUCKET";;
* ) SCM_GIT_CHAR="$SCM_GIT_CHAR_DEFAULT";;
esac
case $remote_domain in
github) SCM_GIT_CHAR="$SCM_GIT_CHAR_GITHUB" ;;
gitlab) SCM_GIT_CHAR="$SCM_GIT_CHAR_GITLAB" ;;
bitbucket) SCM_GIT_CHAR="$SCM_GIT_CHAR_BITBUCKET" ;;
*) SCM_GIT_CHAR="$SCM_GIT_CHAR_DEFAULT" ;;
esac
}

function git_prompt_info {
git_prompt_vars
echo -e " on $SCM_GIT_CHAR_ICON_BRANCH $SCM_PREFIX$SCM_BRANCH$SCM_STATE$SCM_GIT_AHEAD$SCM_GIT_BEHIND$SCM_GIT_STASH$SCM_SUFFIX"
git_prompt_vars
echo -e " on $SCM_GIT_CHAR_ICON_BRANCH $SCM_PREFIX$SCM_BRANCH$SCM_STATE$SCM_GIT_AHEAD$SCM_GIT_BEHIND$SCM_GIT_STASH$SCM_SUFFIX"
}

function _exit-code {
if [[ "$1" -ne 0 ]]; then
exit_code=" ${purple}${EXIT_CODE_ICON}${yellow}${exit_code}${bold_orange}"
else
exit_code="${bold_green}"
fi
if [[ "$1" -ne 0 ]]; then
exit_code=" ${purple}${EXIT_CODE_ICON}${yellow}${exit_code}${bold_orange}"
else
exit_code="${bold_green}"
fi
}

function _prompt {
local exit_code="$?" wrap_char=' ' dir_color=$green ssh_info='' python_venv='' host command_duration=

command_duration=$(_command_duration)

_exit-code exit_code
_git-uptream-remote-logo

history -a

# Detect root shell
if [ "$(whoami)" = root ]; then
dir_color=$red
fi

# Detect ssh
if [[ -n "${SSH_CONNECTION}" ]] && [ "$SSH_INFO" = true ]; then
if [ "$HOST_INFO" = long ]; then
host="\H"
else
host="\h"
fi
ssh_info="${bold_blue}\u${bold_orange}@${cyan}$host ${bold_orange}in"
fi

# Detect python venv
if [[ -n "${CONDA_DEFAULT_ENV}" ]]; then
python_venv="$PYTHON_VENV_CHAR${CONDA_DEFAULT_ENV} "
elif [[ -n "${VIRTUAL_ENV}" ]]; then
python_venv="$PYTHON_VENV_CHAR$(basename "${VIRTUAL_ENV}") "
fi

PS1="\\n${ssh_info} ${purple}$(scm_char)${python_venv}${dir_color}\\w${normal}$(scm_prompt_info)${command_duration}${exit_code}"
[[ ${#PS1} -gt $((COLUMNS*2)) ]] && wrap_char="\\n"
PS1="${PS1}${wrap_char}❯${normal} "
local exit_code="$?" wrap_char=' ' dir_color=$green ssh_info='' python_venv='' host command_duration=

command_duration=$(_command_duration)

_exit-code exit_code
_git-uptream-remote-logo

history -a

# Detect root shell
if [ "$(whoami)" = root ]; then
dir_color=$red
fi

# Detect ssh
if [[ -n "${SSH_CONNECTION}" ]] && [ "$SSH_INFO" = true ]; then
if [ "$HOST_INFO" = long ]; then
host="\H"
else
host="\h"
fi
ssh_info="${bold_blue}\u${bold_orange}@${cyan}$host ${bold_orange}in"
fi

# Detect python venv
if [[ -n "${CONDA_DEFAULT_ENV}" ]]; then
python_venv="$PYTHON_VENV_CHAR${CONDA_DEFAULT_ENV} "
elif [[ -n "${VIRTUAL_ENV}" ]]; then
python_venv="$PYTHON_VENV_CHAR$(basename "${VIRTUAL_ENV}") "
fi

PS1="\\n${ssh_info} ${purple}$(scm_char)${python_venv}${dir_color}\\w${normal}$(scm_prompt_info)${command_duration}${exit_code}"
[[ ${#PS1} -gt $((COLUMNS * 2)) ]] && wrap_char="\\n"
PS1="${PS1}${wrap_char}❯${normal} "
}

safe_append_prompt_command _prompt