Skip to content
Merged
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
10 changes: 8 additions & 2 deletions themes/barbuk/barbuk.theme.bash
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function __git-upstream-remote-logo_prompt() {

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 "
echo "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() {
Expand Down Expand Up @@ -194,7 +194,12 @@ function __python_venv_prompt() {
elif [[ -n "${VIRTUAL_ENV_PROMPT:-}" ]]; then
python_info="${VIRTUAL_ENV_PROMPT}"
elif [[ -f pyproject.toml ]]; then
python_info=$(awk -F'"' '/^requires-python/ {print $2}' pyproject.toml)
# pyproject.toml has no character restrictions on this field, unlike a
# git ref name. Strip anything outside printable ASCII (raw control
# characters, e.g. terminal escape sequences) as well as literal
# backslash-letter escape sequences written as text (e.g. "\e]...\a"),
# which some shells/echo modes can still expand.
python_info=$(awk -F'"' '/^requires-python/ {gsub(/[^\40-\176]|\\[a-zA-Z]/, "", $2); print $2}' pyproject.toml)
[[ -z "${python_info}" ]] && python_info="py"
fi

Expand Down Expand Up @@ -312,6 +317,7 @@ function __prompt-command() {
for segment in $BARBUK_PROMPT; do
local info
info="$(__"${segment}"_prompt)"
info="${info//[[:cntrl:]]/}"
[[ -n "${info}" ]] && PS1+="${info}"
done

Expand Down
Loading