shfmt needs more spaces
parent
0068315c35
commit
9a71556b99
|
|
@ -60,145 +60,144 @@ RBFU_THEME_PROMPT_PREFIX=''
|
||||||
RBFU_THEME_PROMPT_SUFFIX=''
|
RBFU_THEME_PROMPT_SUFFIX=''
|
||||||
|
|
||||||
function __git-uptream-remote-logo_prompt() {
|
function __git-uptream-remote-logo_prompt() {
|
||||||
[[ "$(_git-upstream)" == "" ]] && SCM_GIT_CHAR="$SCM_GIT_CHAR_DEFAULT"
|
[[ "$(_git-upstream)" == "" ]] && SCM_GIT_CHAR="$SCM_GIT_CHAR_DEFAULT"
|
||||||
|
|
||||||
local remote remote_domain
|
local remote remote_domain
|
||||||
remote=$(_git-upstream-remote)
|
remote=$(_git-upstream-remote)
|
||||||
remote_domain=$(git config --get remote."$remote".url | awk -F'[@:.]' '{print $2}')
|
remote_domain=$(git config --get remote."$remote".url | awk -F'[@:.]' '{print $2}')
|
||||||
|
|
||||||
# remove // suffix for https:// url
|
# remove // suffix for https:// url
|
||||||
remote_domain=${remote_domain//\//}
|
remote_domain=${remote_domain//\//}
|
||||||
|
|
||||||
case $remote_domain in
|
case $remote_domain in
|
||||||
github) SCM_GIT_CHAR="$SCM_GIT_CHAR_GITHUB" ;;
|
github) SCM_GIT_CHAR="$SCM_GIT_CHAR_GITHUB" ;;
|
||||||
gitlab) SCM_GIT_CHAR="$SCM_GIT_CHAR_GITLAB" ;;
|
gitlab) SCM_GIT_CHAR="$SCM_GIT_CHAR_GITLAB" ;;
|
||||||
bitbucket) SCM_GIT_CHAR="$SCM_GIT_CHAR_BITBUCKET" ;;
|
bitbucket) SCM_GIT_CHAR="$SCM_GIT_CHAR_BITBUCKET" ;;
|
||||||
*) SCM_GIT_CHAR="$SCM_GIT_CHAR_DEFAULT" ;;
|
*) SCM_GIT_CHAR="$SCM_GIT_CHAR_DEFAULT" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
echo "${purple?}$(scm_char)"
|
echo "${purple?}$(scm_char)"
|
||||||
}
|
}
|
||||||
|
|
||||||
function git_prompt_info() {
|
function git_prompt_info() {
|
||||||
git_prompt_vars
|
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 "
|
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_prompt() {
|
function __exit_prompt() {
|
||||||
if [[ "$exit_code" -ne 0 ]]; then
|
if [[ "$exit_code" -ne 0 ]]; then
|
||||||
echo "${purple?}${EXIT_CODE_ICON}${yellow?}${exit_code}${bold_orange?} "
|
echo "${purple?}${EXIT_CODE_ICON}${yellow?}${exit_code}${bold_orange?} "
|
||||||
else
|
else
|
||||||
echo "${bold_green}"
|
echo "${bold_green}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function __aws_profile_prompt() {
|
function __aws_profile_prompt() {
|
||||||
if [[ -n "${AWS_PROFILE}" ]]; then
|
if [[ -n "${AWS_PROFILE}" ]]; then
|
||||||
echo -n "${bold_purple?}${AWS_PROFILE_CHAR}${normal?}${AWS_PROFILE} "
|
echo -n "${bold_purple?}${AWS_PROFILE_CHAR}${normal?}${AWS_PROFILE} "
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function __scaleway_profile_prompt() {
|
function __scaleway_profile_prompt() {
|
||||||
if [[ -n "${SCW_PROFILE}" ]]; then
|
if [[ -n "${SCW_PROFILE}" ]]; then
|
||||||
echo -n "${bold_purple?}${SCALEWAY_PROFILE_CHAR}${normal?}${SCW_PROFILE} "
|
echo -n "${bold_purple?}${SCALEWAY_PROFILE_CHAR}${normal?}${SCW_PROFILE} "
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function __gcloud_prompt() {
|
function __gcloud_prompt() {
|
||||||
local active_gcloud_account=""
|
local active_gcloud_account=""
|
||||||
|
|
||||||
active_gcloud_account="$(active_gcloud_account_prompt)"
|
active_gcloud_account="$(active_gcloud_account_prompt)"
|
||||||
[[ -n "${active_gcloud_account}" ]] && echo "${bold_purple?}${GCLOUD_CHAR}${normal?}${active_gcloud_account} "
|
[[ -n "${active_gcloud_account}" ]] && echo "${bold_purple?}${GCLOUD_CHAR}${normal?}${active_gcloud_account} "
|
||||||
}
|
}
|
||||||
|
|
||||||
function __cloud_prompt() {
|
function __cloud_prompt() {
|
||||||
__aws_profile_prompt
|
__aws_profile_prompt
|
||||||
__scaleway_profile_prompt
|
__scaleway_profile_prompt
|
||||||
__gcloud_prompt
|
__gcloud_prompt
|
||||||
}
|
}
|
||||||
|
|
||||||
function __terraform_prompt() {
|
function __terraform_prompt() {
|
||||||
local terraform_workspace=""
|
local terraform_workspace=""
|
||||||
|
|
||||||
if [ -d .terraform ]; then
|
if [ -d .terraform ]; then
|
||||||
terraform_workspace="$(terraform_workspace_prompt)"
|
terraform_workspace="$(terraform_workspace_prompt)"
|
||||||
[[ -n "${terraform_workspace}" ]] && echo "${bold_purple?}${TERRAFORM_CHAR}${normal?}${terraform_workspace} "
|
[[ -n "${terraform_workspace}" ]] && echo "${bold_purple?}${TERRAFORM_CHAR}${normal?}${terraform_workspace} "
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function __node_prompt() {
|
function __node_prompt() {
|
||||||
local node_version=""
|
local node_version=""
|
||||||
|
|
||||||
node_version="$(node_version_prompt)"
|
node_version="$(node_version_prompt)"
|
||||||
[[ -n "${node_version}" ]] && echo "${bold_purple?}${NODE_CHAR}${normal?}${node_version} "
|
[[ -n "${node_version}" ]] && echo "${bold_purple?}${NODE_CHAR}${normal?}${node_version} "
|
||||||
}
|
}
|
||||||
|
|
||||||
function __ruby_prompt() {
|
function __ruby_prompt() {
|
||||||
local ruby_version=""
|
local ruby_version=""
|
||||||
|
|
||||||
ruby_version="$(ruby_version_prompt)"
|
ruby_version="$(ruby_version_prompt)"
|
||||||
[[ -n "${ruby_version}" ]] && echo "${bold_purple?}${RUBY_CHAR}${normal?}${ruby_version} "
|
[[ -n "${ruby_version}" ]] && echo "${bold_purple?}${RUBY_CHAR}${normal?}${ruby_version} "
|
||||||
}
|
}
|
||||||
|
|
||||||
function __ssh_prompt() {
|
function __ssh_prompt() {
|
||||||
# Detect ssh
|
# Detect ssh
|
||||||
if [[ -n "${SSH_CONNECTION}" ]] && [ "$SSH_INFO" = true ]; then
|
if [[ -n "${SSH_CONNECTION}" ]] && [ "$SSH_INFO" = true ]; then
|
||||||
if [ "$HOST_INFO" = long ]; then
|
if [ "$HOST_INFO" = long ]; then
|
||||||
host="\H"
|
host="\H"
|
||||||
else
|
else
|
||||||
host="\h"
|
host="\h"
|
||||||
fi
|
fi
|
||||||
echo "${bold_blue?}\u${bold_orange?}@${cyan?}$host ${bold_orange?}in "
|
echo "${bold_blue?}\u${bold_orange?}@${cyan?}$host ${bold_orange?}in "
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function __python_venv_prompt() {
|
function __python_venv_prompt() {
|
||||||
# Detect python venv
|
# Detect python venv
|
||||||
if [[ -n "${CONDA_DEFAULT_ENV}" ]]; then
|
if [[ -n "${CONDA_DEFAULT_ENV}" ]]; then
|
||||||
echo "${bold_purple?}$PYTHON_VENV_CHAR${normal?}${CONDA_DEFAULT_ENV} "
|
echo "${bold_purple?}$PYTHON_VENV_CHAR${normal?}${CONDA_DEFAULT_ENV} "
|
||||||
elif [[ -n "${VIRTUAL_ENV}" ]]; then
|
elif [[ -n "${VIRTUAL_ENV}" ]]; then
|
||||||
echo "${bold_purple?}$PYTHON_VENV_CHAR${normal?}$(basename "${VIRTUAL_ENV}") "
|
echo "${bold_purple?}$PYTHON_VENV_CHAR${normal?}$(basename "${VIRTUAL_ENV}") "
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function __path_prompt() {
|
function __path_prompt() {
|
||||||
local dir_color=${green?}
|
local dir_color=${green?}
|
||||||
# Detect root shell
|
# Detect root shell
|
||||||
if [ "$(whoami)" = root ]; then
|
if [ "$(whoami)" = root ]; then
|
||||||
dir_color=${red?}
|
dir_color=${red?}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "${dir_color}\w${normal} "
|
echo "${dir_color}\w${normal} "
|
||||||
}
|
}
|
||||||
|
|
||||||
function __scm_prompt() {
|
function __scm_prompt() {
|
||||||
scm_prompt_info
|
scm_prompt_info
|
||||||
}
|
}
|
||||||
|
|
||||||
function __duration_prompt() {
|
function __duration_prompt() {
|
||||||
[[ -n "$command_duration" ]] && echo "${command_duration} "
|
[[ -n "$command_duration" ]] && echo "${command_duration} "
|
||||||
}
|
}
|
||||||
|
|
||||||
function __prompt-command() {
|
function __prompt-command() {
|
||||||
exit_code="$?"
|
exit_code="$?"
|
||||||
command_duration=$(_command_duration)
|
command_duration=$(_command_duration)
|
||||||
local wrap_char
|
local wrap_char
|
||||||
|
|
||||||
# Generate prompt
|
# Generate prompt
|
||||||
PS1="\n "
|
PS1="\n "
|
||||||
for segment in $BARBUK_PROMPT; do
|
for segment in $BARBUK_PROMPT; do
|
||||||
local info
|
local info
|
||||||
info="$(__"${segment}"_prompt)"
|
info="$(__"${segment}"_prompt)"
|
||||||
[[ -n "${info}" ]] && PS1+="${info}"
|
[[ -n "${info}" ]] && PS1+="${info}"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Cut prompt when it's too long
|
# Cut prompt when it's too long
|
||||||
if [[ ${#PS1} -gt $((COLUMNS * 2)) ]]; then
|
if [[ ${#PS1} -gt $((COLUMNS * 2)) ]]; then
|
||||||
wrap_char="\n"
|
wrap_char="\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PS1="${PS1}${wrap_char}❯${normal} "
|
PS1="${PS1}${wrap_char}❯${normal} "
|
||||||
}
|
}
|
||||||
|
|
||||||
safe_append_prompt_command __prompt-command
|
safe_append_prompt_command __prompt-command
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue