summaryrefslogtreecommitdiff
path: root/dot-bashrc
diff options
context:
space:
mode:
authorJosé Juan Loeza Sierra <jj@xz6ze.com>2025-11-19 12:53:07 -0800
committerJosé Juan Loeza Sierra <jj@xz6ze.com>2025-11-19 12:53:07 -0800
commit425ad95a972210b07edba4db43206068aa976ab8 (patch)
treeb318745d34bdeaf59f463a12cb172bb41418acfa /dot-bashrc
parentaf4a04b8f6172131c0e143b112bc66ef11ec0f18 (diff)
add script for reporting directy changes to foot
This is done to that doing ctrl+shift+n will spawn a new instance in the cwd. See https://codeberg.org/dnkl/foot/wiki#spawning-new-terminal-instances-in-the-current-working-directory for more info.
Diffstat (limited to 'dot-bashrc')
-rw-r--r--dot-bashrc18
1 files changed, 18 insertions, 0 deletions
diff --git a/dot-bashrc b/dot-bashrc
index 1b215cb..3df8ad2 100644
--- a/dot-bashrc
+++ b/dot-bashrc
@@ -101,3 +101,21 @@ eval "$(zoxide init bash)"
if [ "$CONTAINER_ID" = "dev" ]; then
source ~/.bashrc.d/dev.bashrc
fi
+
+# for spawning new terminal in cwd
+# see https://codeberg.org/dnkl/foot/wiki#spawning-new-terminal-instances-in-the-current-working-directory
+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