| @@ -88,6 +88,7 @@ _agent_vm_ensure_running() { |
| 88 | 88 | limactl stop "$vm_name" &>/dev/null |
| 89 | 89 | limactl delete "$vm_name" --force &>/dev/null |
| 90 | 90 | rm -f "$AGENT_VM_STATE_DIR/.agent-vm-version-${vm_name}" |
| 91 | +新增: rm -f "$AGENT_VM_STATE_DIR/.agent-vm-term-${vm_name}" |
| 91 | 92 | fi |
| 92 | 93 | |
| 93 | 94 | if ! _agent_vm_exists "$vm_name"; then |
| @@ -157,6 +158,20 @@ _agent_vm_ensure_running() { |
| 157 | 158 | limactl start "$vm_name" &>/dev/null |
| 158 | 159 | fi |
| 159 | 160 | |
| 161 | +新增: # Install the host's terminfo entry inside the VM so non-standard terminals |
| 162 | +新增: # (xterm-ghostty, xterm-kitty, …) work correctly. Without this, zsh/ZLE |
| 163 | +新增: # can't decode keys → broken backspace, arrows, etc. Cached per-VM so we only |
| 164 | +新增: # pay the limactl shell roundtrip when $TERM actually changes. |
| 165 | +新增: local term_cache="$AGENT_VM_STATE_DIR/.agent-vm-term-${vm_name}" |
| 166 | +新增: if [[ -n "${TERM:-}" ]] && [[ "$(cat "$term_cache" 2>/dev/null)" != "$TERM" ]] \ |
| 167 | +新增: && infocmp -x "$TERM" &>/dev/null; then |
| 168 | +新增: if infocmp -x "$TERM" | limactl shell "$vm_name" sudo tic -x - &>/dev/null; then |
| 169 | +新增: echo "$TERM" > "$term_cache" |
| 170 | +新增: else |
| 171 | +新增: echo "Warning: failed to install '$TERM' terminfo inside VM." >&2 |
| 172 | +新增: fi |
| 173 | +新增: fi |
| 174 | +新增: |
| 160 | 175 | # Run per-user runtime script if it exists |
| 161 | 176 | if [ -f "$AGENT_VM_STATE_DIR/runtime.sh" ]; then |
| 162 | 177 | echo "Running user runtime setup..." |
| @@ -632,6 +647,7 @@ _agent_vm_destroy() { |
| 632 | 647 | limactl stop "$vm_name" &>/dev/null |
| 633 | 648 | limactl delete "$vm_name" --force &>/dev/null |
| 634 | 649 | rm -f "$AGENT_VM_STATE_DIR/.agent-vm-version-${vm_name}" |
| 650 | +新增: rm -f "$AGENT_VM_STATE_DIR/.agent-vm-term-${vm_name}" |
| 635 | 651 | echo "VM destroyed." |
| 636 | 652 | } |
| 637 | 653 | |
| @@ -656,6 +672,7 @@ _agent_vm_destroy_all() { |
| 656 | 672 | limactl stop "$vm" &>/dev/null |
| 657 | 673 | limactl delete "$vm" --force &>/dev/null |
| 658 | 674 | rm -f "$AGENT_VM_STATE_DIR/.agent-vm-version-${vm}" |
| 675 | +新增: rm -f "$AGENT_VM_STATE_DIR/.agent-vm-term-${vm}" |
| 659 | 676 | done |
| 660 | 677 | echo "All VMs destroyed." |
| 661 | 678 | } |