diff options
-rw-r--r-- | .bashrc | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -66,8 +66,24 @@ rand_util() { pacman -Ql coreutils | grep bin | awk '{print $2}' | sed '/^.*\/$/d' | shuf -n 1 - | xargs man } - # set prompt PS1='[\e[31m$(get_nonzero_retcode)\e[0m\e[32;1m$(date +"%H:%M:%S")\e[0m \e[35;1m\u@\h\e[0m\e[33;1m$(parse_git_branch)\e[0m \e[36;1m\W\e[0m] $ ' +# Emit OSC-7 escape sequence to allow the foot terminal emulator to spawn a new +# terminal in the same folder. +osc7_cwd() { + local strlen=${#PWD} + local encoded="" + local pos c o + for (( pos=0; pos<strlen; pos++ )); do + c=${PWD:$pos:1} + case "$c" in + [-/:_.!\'\(\)~[:alnum:]] ) o="${c}" ;; + * ) printf -v o '%%%02X' "'${c}" ;; + esac + encoded+="${o}" + done + printf '\e]7;file://%s%s\e\\' "${HOSTNAME}" "${encoded}" +} +PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }osc7_cwd |