Skip to content

Commit 7fa8027

Browse files
committed
more zshrc fixups. dont send large commands, and fix autoload ordering
1 parent f14a3e6 commit 7fa8027

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

frontend/app/view/term/termwrap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ function handleOsc16162Command(data: string, blockId: string, loaded: boolean, t
201201
if (cmd.data.cmd64) {
202202
const decodedLen = Math.ceil(cmd.data.cmd64.length * 0.75);
203203
if (decodedLen > 8192) {
204-
rtInfo["shell:lastcmd"] = `# command too large to store (${decodedLen} bytes)`;
204+
rtInfo["shell:lastcmd"] = `# command too large (${decodedLen} bytes)`;
205205
} else {
206206
try {
207207
const decodedCmd = atob(cmd.data.cmd64);

pkg/util/shellutil/shellintegration/zsh_zshrc.sh

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,19 @@ _waveterm_si_precmd() {
6666

6767
_waveterm_si_preexec() {
6868
_waveterm_si_blocked && return
69-
local cmd64
70-
cmd64=$(printf '%s' "$1" | base64 2>/dev/null | tr -d '\n\r')
71-
if [ -n "$cmd64" ]; then
69+
local cmd_length=${#1}
70+
if [ "$cmd_length" -gt 8192 ]; then
71+
local cmd64
72+
cmd64=$(printf '# command too large (%d bytes)' "$cmd_length" | base64 2>/dev/null | tr -d '\n\r')
7273
printf '\033]16162;C;{"cmd64":"%s"}\007' "$cmd64"
7374
else
74-
printf '\033]16162;C\007'
75+
local cmd64
76+
cmd64=$(printf '%s' "$1" | base64 2>/dev/null | tr -d '\n\r')
77+
if [ -n "$cmd64" ]; then
78+
printf '\033]16162;C;{"cmd64":"%s"}\007' "$cmd64"
79+
else
80+
printf '\033]16162;C\007'
81+
fi
7582
fi
7683
}
7784

@@ -95,8 +102,8 @@ _waveterm_si_inputempty() {
95102
fi
96103
}
97104

105+
autoload -Uz add-zle-hook-widget 2>/dev/null
98106
if (( $+functions[add-zle-hook-widget] )); then
99-
autoload -Uz add-zle-hook-widget
100107
add-zle-hook-widget zle-line-init _waveterm_si_inputempty
101108
add-zle-hook-widget zle-line-pre-redraw _waveterm_si_inputempty
102109
fi

0 commit comments

Comments
 (0)