diff --git a/sh/bashrc b/sh/bashrc index 6083baa..3f905e9 100644 --- a/sh/bashrc +++ b/sh/bashrc @@ -59,6 +59,14 @@ COLOR_RESET='\[\e[0m\]' PROMPT_SUCCESS_COLOR='\[\e[0;34m\]' PROMPT_FAILURE_COLOR='\[\e[0;31m\]' DIR_COLOR='\[\e[0;33m\]' +sps() { + name="$PWD" + [[ "$name" =~ ^"$HOME"(/|$) ]] && name="~${name#$HOME}" + curdir=$(echo "$PWD" | sed -r 's|.*/(.+)$|\1|g') + name=$(echo "$name" | sed -r 's|/(..)[^/]*|/\1|g' | sed -r 's|(.*/)(.+)$|\1|g') + [[ "$name" == "~" ]] && curdir="" + echo "$name$curdir" +} prompt_command_func() { RET=$? @@ -67,7 +75,7 @@ prompt_command_func() else STATUS_COLOR=$PROMPT_FAILURE_COLOR fi; - PS1="$STATUS_COLOR\u@\h$COLOR_RESET $DIR_COLOR\w$COLOR_RESET " + PS1="$STATUS_COLOR\u@\h$COLOR_RESET $DIR_COLOR$(eval "sps")$COLOR_RESET " } export PROMPT_COMMAND="prompt_command_func"