@@ -5637,6 +5637,7 @@ _p9k_preexec2() {
5637
5637
typeset -g _p9k__preexec_cmd=$2
5638
5638
_p9k__timer_start=EPOCHREALTIME
5639
5639
P9K_TTY=old
5640
+ (( ! $+_p9k__iterm_cmd )) || _p9k_iterm2_preexec
5640
5641
}
5641
5642
5642
5643
function _p9k_prompt_net_iface_init() {
@@ -6873,6 +6874,10 @@ _p9k_precmd_impl() {
6873
6874
_p9k__zle_state=insert
6874
6875
6875
6876
(( ++_p9k__prompt_idx ))
6877
+
6878
+ if (( $+_p9k__iterm_cmd )); then
6879
+ _p9k_iterm2_precmd $__p9k_new_status
6880
+ fi
6876
6881
fi
6877
6882
6878
6883
_p9k_fetch_cwd
@@ -8600,6 +8605,20 @@ _p9k_init_vcs() {
8600
8605
(( $+GITSTATUS_DAEMON_PID_POWERLEVEL9K )) || _p9k__instant_prompt_disabled=1
8601
8606
}
8602
8607
8608
+ function _p9k_iterm2_precmd() {
8609
+ builtin zle && return
8610
+ if (( _p9k__iterm_cmd )) && [[ -t 1 ]]; then
8611
+ (( _p9k__iterm_cmd == 1 )) && builtin print -n '\e]133;C;\a'
8612
+ builtin printf '\e]133;D;%s\a' $1
8613
+ fi
8614
+ typeset -gi _p9k__iterm_cmd=1
8615
+ }
8616
+
8617
+ function _p9k_iterm2_preexec() {
8618
+ [[ -t 1 ]] && builtin print -n '\e]133;C;\a'
8619
+ typeset -gi _p9k__iterm_cmd=2
8620
+ }
8621
+
8603
8622
_p9k_init() {
8604
8623
_p9k_init_vars
8605
8624
_p9k_restore_state || _p9k_init_cacheable
@@ -8663,6 +8682,13 @@ _p9k_init() {
8663
8682
functions[iterm2_precmd]='local _p9k_status=$?; zle && return; () { return $_p9k_status; }; '$_p9k__iterm2_precmd
8664
8683
fi
8665
8684
8685
+ if (( _POWERLEVEL9K_TERM_SHELL_INTEGRATION &&
8686
+ ! $+_z4h_iterm_cmd &&
8687
+ ! $+functions[iterm2_decorate_prompt] &&
8688
+ ! $+functions[iterm2_precmd] )); then
8689
+ typeset -gi _p9k__iterm_cmd=0
8690
+ fi
8691
+
8666
8692
if _p9k_segment_in_use todo; then
8667
8693
if [[ -n ${_p9k__todo_command::=${commands[todo.sh]}} ]]; then
8668
8694
local todo_global=/etc/todo/config
0 commit comments