Fix bash prompt so last path part is not shortened
This commit is contained in:
parent
af4be9aa3a
commit
4fcf512062
1 changed files with 3 additions and 3 deletions
|
@ -6,7 +6,7 @@ PROMPT_SUCCESS_COLOR='\[\e[0;34m\]'
|
||||||
PROMPT_FAILURE_COLOR='\[\e[0;31m\]'
|
PROMPT_FAILURE_COLOR='\[\e[0;31m\]'
|
||||||
DIR_COLOR='\[\e[0;35m\]'
|
DIR_COLOR='\[\e[0;35m\]'
|
||||||
|
|
||||||
MAX_PATH_PIECE_CHARS=3
|
MAX_PATH_PIECE_CHARS=${BASH_PROMPT_MAX_PATH_PIECE_CHARS:-3}
|
||||||
|
|
||||||
# prompt rendering functions
|
# prompt rendering functions
|
||||||
preprocess_pwd() {
|
preprocess_pwd() {
|
||||||
|
@ -14,9 +14,9 @@ preprocess_pwd() {
|
||||||
[[ "$p" == "/" ]] && echo "/" && return 1
|
[[ "$p" == "/" ]] && echo "/" && return 1
|
||||||
[[ "$p" == "${NICE_HOME}" ]] && echo "~" && return 0
|
[[ "$p" == "${NICE_HOME}" ]] && echo "~" && return 0
|
||||||
# with ellipsis
|
# with ellipsis
|
||||||
# echo "$(<<< "$p" cut -c2- | awk '{split($0,p,"/");for(k in p){if(length(p[k])>'"$((MAX_PATH_PIECE_CHARS+1))"'){printf "/%.'"$((MAX_PATH_PIECE_CHARS))"'s…",p[k]}else{printf "/%s",p[k]}}}')"
|
#echo "$(<<< "$p" cut -c2- | awk '{split($0,p,"/");for(k in p){if(k==length(p)){printf "/%s",p[k]}else{if(length(p[k])>'"$((MAX_PATH_PIECE_CHARS+1))"'){printf "/%.'"$((MAX_PATH_PIECE_CHARS))"'s…",p[k]}else{printf "/%s",p[k]}}}}')"
|
||||||
# without ellipsis
|
# without ellipsis
|
||||||
echo "$(<<< "$p" cut -c2- | awk '{split($0,p,"/");for(k in p){printf "/%.'"$MAX_PATH_PIECE_CHARS"'s",p[k]}}')"
|
echo "$(<<< "$p" cut -c2- | awk '{split($0,p,"/");for(k in p){if(k==length(p)){printf "/%s",p[k]}else{printf "/%.'"$MAX_PATH_PIECE_CHARS"'s",p[k]}}}')"
|
||||||
}
|
}
|
||||||
export -f "preprocess_pwd"
|
export -f "preprocess_pwd"
|
||||||
|
|
||||||
|
|
Reference in a new issue