diff --git a/bash.bashrc b/bash.bashrc index 32e3094..c677210 100644 --- a/bash.bashrc +++ b/bash.bashrc @@ -96,8 +96,10 @@ __prompt_command() { PS1+="${R}";; esac PS1+="\h" - - PS1+=" ${Cya}\w${R}" + + local pwd='~' + [ "$PWD" != "$HOME" ] && pwd=${PWD/#$HOME\//\~\/} + PS1+=" ${Cya}${pwd}$(__vte_osc7)${R}" if hash git 2>&-; then # git command exists @@ -134,10 +136,33 @@ __prompt_command() { fi PS1+=" $PROMPT ${R}" + } + +__vte_osc7 () { + printf "\033]7;file://%s%s\007" "${HOSTNAME:-}" "$(__vte_urlencode "${PWD}")" +} + +__vte_urlencode() ( + # This is important to make sure string manipulation is handled + # byte-by-byte. + LC_ALL=C + str="$1" + while [ -n "$str" ]; do + safe="${str%%[!a-zA-Z0-9/:_\.\-\!\'\(\)~]*}" + printf "%s" "$safe" + str="${str#"$safe"}" + if [ -n "$str" ]; then + printf "%%%02X" "'$str" + str="${str#?}" + fi + done +) + PROMPT_COMMAND='__prompt_command' # Func to gen PS1 after CMDs + DEBIAN_BASH_DIR=/opt/debian-bash # You may uncomment the following lines if you want `ls' to be colorized: