summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.bashrc18
1 files changed, 17 insertions, 1 deletions
diff --git a/.bashrc b/.bashrc
index b1740d0..a1ae98b 100644
--- a/.bashrc
+++ b/.bashrc
@@ -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