From 6708da43a1e5012f049cd34c8eec3973b60b6554 Mon Sep 17 00:00:00 2001 From: Roman Perepelitsa Date: Sat, 17 Aug 2024 09:47:06 +0200 Subject: [PATCH] add cmdline_url to 133;C when KITTY_SHELL_INTEGRATION is defined --- internal/p10k.zsh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index fb724cff..3aee54e6 100644 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -5812,7 +5812,7 @@ _p9k_preexec2() { typeset -g _p9k__preexec_cmd=$2 _p9k__timer_start=EPOCHREALTIME P9K_TTY=old - (( ! $+_p9k__iterm_cmd )) || _p9k_iterm2_preexec + (( ! $+_p9k__iterm_cmd )) || _p9k_iterm2_preexec "$1" } function _p9k_prompt_net_iface_init() { @@ -8877,7 +8877,17 @@ function _p9k_iterm2_precmd() { } function _p9k_iterm2_preexec() { - [[ -t 1 ]] && builtin print -n '\e]133;C;\a' + if [[ -t 1 ]]; then + if (( ${+KITTY_SHELL_INTEGRATION} )); then + () { + emulate -L zsh -o extended_glob -o no_multibyte + local MATCH MBEGIN MEND + builtin printf '\e]133;C;cmdline_url=%s\a' "${1//(#m)[^a-zA-Z0-9"\/:_.-!'()~"]/%${(l:2::0:)$(([##16]#MATCH))}}" + } "$1" + else + builtin print -n '\e]133;C;\a' + fi + fi typeset -gi _p9k__iterm_cmd=2 } @@ -9483,7 +9493,7 @@ if [[ $__p9k_dump_file != $__p9k_instant_prompt_dump_file && -n $__p9k_instant_p zf_rm -f -- $__p9k_instant_prompt_dump_file{,.zwc} 2>/dev/null fi -typeset -g P9K_VERSION=1.20.11 +typeset -g P9K_VERSION=1.20.12 if [[ ${VSCODE_SHELL_INTEGRATION-} == <1-> && ${+__p9k_force_term_shell_integration} == 0 ]]; then typeset -gri __p9k_force_term_shell_integration=1