From ab8722f04217b52870d91403e746de136c31e0cd Mon Sep 17 00:00:00 2001 From: pvincent Date: Tue, 30 Mar 2021 08:26:49 +0400 Subject: [PATCH] tilix fix --- bash.bashrc | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) 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: