beatific: fix prompt path shortening
This commit is contained in:
parent
bf5170c67f
commit
652d8d0805
|
@ -1,20 +1,25 @@
|
||||||
# Set the title bar to user@host: pwd
|
# Set the title bar to user@host: pwd
|
||||||
_TITLE_BAR="\u@\h: \w"
|
_TITLE_BAR="\u@\h: \w"
|
||||||
_SET_TITLE_BAR="\[\e]0;$_TITLE_BAR\a\]"
|
_SET_TITLE_BAR="\[\e]0;$_TITLE_BAR\a\]"
|
||||||
# Shorten $HOME to ~ in PWD
|
# Shorten $HOME to ~ in PWD and shorten other path dir names to one letter
|
||||||
_pwd_home () {
|
_pwd() {
|
||||||
if [[ "$PWD" =~ ^"$HOME"(/|$) ]]; then
|
if [[ "$PWD" =~ ^"$HOME"($) ]]; then
|
||||||
echo "~${PWD#$HOME}"
|
printf "~"
|
||||||
|
elif [[ "$PWD" = "/" ]]; then
|
||||||
|
printf "/"
|
||||||
else
|
else
|
||||||
echo $PWD
|
if [[ "$PWD" =~ ^"$HOME"/ ]]; then
|
||||||
|
printf "~"
|
||||||
|
DIR="${PWD#$HOME}"
|
||||||
|
else
|
||||||
|
DIR="$PWD"
|
||||||
|
fi
|
||||||
|
for path_elem in $(dirname "$DIR" | tr / '\n' | grep . | cut -c-1); do
|
||||||
|
printf '/%s' $path_elem
|
||||||
|
done
|
||||||
|
printf "/$(basename "$DIR")"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
# Shorten path dir names
|
|
||||||
_pwd () {
|
|
||||||
DIR=$(_pwd_home)
|
|
||||||
[ "$DIR" != "/" ] && [ "$DIR" != "~" ] && printf '%s/' $(dirname "$DIR" | tr / '\n' | cut -c-1)
|
|
||||||
printf "$(basename "$DIR")"
|
|
||||||
}
|
|
||||||
_DIR='$(_pwd)'
|
_DIR='$(_pwd)'
|
||||||
# Color codes
|
# Color codes
|
||||||
_GREEN="\[\033[32;1m\]"
|
_GREEN="\[\033[32;1m\]"
|
||||||
|
|
Loading…
Reference in New Issue