Moved my Python prompt to https://git.afpy.org/mdk/python-prompt.
This commit is contained in:
parent
546bc3f01d
commit
79a87884db
51
.bashrc
51
.bashrc
|
@ -66,7 +66,7 @@ alias rekey='ssh-add -e /usr/lib/x86_64-linux-gnu/opensc-pkcs11.so >/dev/null 2>
|
|||
|
||||
export PYTHONDEVMODE=y
|
||||
|
||||
for extra in /etc/bash_completion ~/.bash_aliases ~/.my_bashrc ~/.git-prompt.sh ~/clones/mdk/compile-python/compile-python.sh
|
||||
for extra in /etc/bash_completion ~/.bash_aliases ~/.my_bashrc ~/.git-prompt.sh ~/clones/mdk/compile-python/compile-python.sh ~/clones/mdk/python-prompt/python-prompt.sh
|
||||
do
|
||||
if [ -f "$extra" ]
|
||||
then
|
||||
|
@ -74,50 +74,6 @@ do
|
|||
fi
|
||||
done
|
||||
|
||||
trim() {
|
||||
local var="$*"
|
||||
# remove leading whitespace characters
|
||||
var="${var#"${var%%[![:space:]]*}"}"
|
||||
# remove trailing whitespace characters
|
||||
var="${var%"${var##*[![:space:]]}"}"
|
||||
printf '%s' "$var"
|
||||
}
|
||||
|
||||
shortest()
|
||||
{
|
||||
# Returns the shortest of two strings
|
||||
if [[ ${#1} -lt ${#2} ]]
|
||||
then
|
||||
printf "%s" "$1"
|
||||
else
|
||||
printf "%s" "$2"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
python_ps1()
|
||||
{
|
||||
local relative venvpath pyversion _
|
||||
|
||||
venvpath="$(which python 2>/dev/null)"
|
||||
venvpath="${venvpath%/bin/python}"
|
||||
|
||||
if [[ -z "$venvpath" ]] || [[ "$venvpath" == "/usr" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
relative="$(realpath --relative-to="$(pwd)" -s "$venvpath")"
|
||||
venvpath="$(shortest "$venvpath" "$relative")"
|
||||
|
||||
if [[ "$venvpath" == ".venv" ]]; then
|
||||
venvpath="" # No need to tell me my venv is in .venv, I can guess it.
|
||||
fi
|
||||
|
||||
read -r _ pyversion <<<"$(python --version)"
|
||||
|
||||
printf "$1" "$(trim "$venvpath $pyversion")"
|
||||
}
|
||||
|
||||
if [[ "$TERM" != 'dumb' ]]
|
||||
then
|
||||
_TITLE="\[\e]0;\H \W\a\]"
|
||||
|
@ -138,9 +94,8 @@ PY_BLUE_FG='\e[38;2;53;112;160m'
|
|||
PY_BLUE_BG='\e[48;2;53;112;160m'
|
||||
PY_YELLOW_FG='\e[38;2;255;222;87m'
|
||||
PY_YELLOW_BG='\e[48;2;255;222;87m'
|
||||
# 🬫🬛
|
||||
# 🭮🭬
|
||||
PY_PS1='$(python_ps1 "${PY_BLUE_FG}🭮${PY_BLUE_BG}${PY_YELLOW_FG} %s \e[0m${PY_BLUE_FG}🭬\e[0m")'
|
||||
|
||||
PY_PS1='$(python_prompt "${PY_BLUE_FG}🭮${PY_BLUE_BG}${PY_YELLOW_FG} %s \e[0m${PY_BLUE_FG}🭬\e[0m")'
|
||||
GIT_PS1='$(__git_ps1 "${GIT_RED_FG}🭮${GIT_RED_BG}\e[97m %s \e[0m${GIT_RED_FG}🭬\e[0m")'
|
||||
PS1="${_TITLE}${_PREV_FAIL}${USERNAME_COLOR}\u\e[0m@${HOSTNAME_COLOR}\H\e[0m:\e[32m\w\e[0m${PY_PS1}${GIT_PS1}\n\$ "
|
||||
|
||||
|
|
Loading…
Reference in New Issue