diff options
| author | Robert Günzler <r@gnzler.io> | 2022-04-15 15:21:56 +0200 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2022-04-15 15:21:56 +0200 |
| commit | 4a4120e277604b8852bd38c8f8642c6b5d3ef713 (patch) | |
| tree | 55a0102203e4a045759da6a320fd4ee1faa174cc /.bashrc | |
| parent | c2e451a6f8c04da204bf6e1e7faae5925e80b911 (diff) | |
setup bash to emit osc7 (when changing workdir)
Diffstat (limited to '.bashrc')
| -rw-r--r-- | .bashrc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/.bashrc b/.bashrc index 24f05d2..fb80b92 100644 --- a/.bashrc +++ b/.bashrc @@ -58,6 +58,23 @@ safe_load "$HOME/.keychain/$(hostname)-sh-gpg" # fi # } +# OSC7 escapte sequence +# https://codeberg.org/dnkl/foot/wiki#user-content-how-to-configure-my-shell-to-emit-the-osc-7-escape-sequence +_urlencode() { + local length="${#1}" + for ((i = 0; i < length; i++)); do + local c="${1:$i:1}" + case $c in + %) printf '%%%02X' "'$c" ;; + *) printf "%s" "$c" ;; + esac + done +} +_osc7_cwd() { + printf '\e]7;file://%s%s\e\\' "$HOSTNAME" "$(_urlencode "$PWD")" +} +PROMPT_COMMAND+=";_osc7_cwd" + # Alias shell commands # alias logout='dbus-send --session --type=method_call --print-reply --dest=' alias vim=nvim |