warpdotdev / Warp

Warp is the agentic development environment, built for coding with multiple AI agents.
https://warp.dev
Other
24.02k stars 488 forks source link

Last Command shows Zsh prompt if #6609

Open emayecs opened 3 weeks ago

emayecs commented 3 weeks ago

Pre-submit Checks

Describe the bug

When I open up a new tab in Warp and press the up-arrow (last command) quickly before suggestions load, the Warp configuration script loads in my terminal:

read -r -d '' WARP_BOOTSTRAP_VAR << 'EOM'; eval "$WARP_BOOTSTRAP_VAR"; unset WARP_BOOTSTRAP_VAR if [[ -z $WARP_BOOTSTRAPPED ]]; then if (( ${+ORIGINAL_PS2} )); then PS2="$ORIGINAL_PS2" else unset PS2 fi DCS_START="$(printf '\eP$')" DCS_JSON_MARKER="d" DCS_END="$(printf '\x9c')" OSC_START_GENERATOR_OUTPUT="$(printf '\e]9277;A\a')" OSC_END_GENERATOR_OUTPUT="$(printf '\e]9277;B\a')" OSC_START="$(printf '\e]9278;')" OSC_END="$(printf '\a')" OSC_PARAM_SEPARATOR=";" OSC_RESET_GRID="$(printf '\e]9279\a')" if [[ ! -z "$WARP_INITIAL_WORKING_DIR" ]]; then cd "$WARP_INITIAL_WORKING_DIR" >/dev/null 2>&1 unset WARP_INITIAL_WORKING_DIR fi unsetopt hist_ignore_space warp_send_json_message () { local msg=$(warp_hex_encode_string "$1") if [ "$WARP_USING_WINDOWS_CON_PTY" = true ]; then printf $OSC_START$DCS_JSON_MARKER$OSC_PARAM_SEPARATOR$msg$OSC_END else printf "%b%b%s%b" $DCS_START $DCS_JSON_MARKER $msg $DCS_END fi } warp_maybe_send_reset_grid_osc() { if [ "$WARP_USING_WINDOWS_CON_PTY" = true ]; then printf $OSC_RESET_GRID fi } warp_send_generator_output_osc() { local hex_encoded_message=$(warp_hex_encode_string "$1") local byte_count=$(LC_ALL="C"; printf "${#hex_encoded_message}") printf "%b%i;%s%b" $OSC_START_GENERATOR_OUTPUT $byte_count $hex_encoded_message $OSC_END_GENERATOR_OUTPUT warp_maybe_send_reset_grid_osc } _warp_execute_command() { local command_id=$1 local command=("${(@)@:2}") local raw_output raw_output=$(eval "$command" 2>&1) local exit_code=$? warp_send_generator_output_osc "$command_id;$raw_output;$exit_code" } _warp_run_generator_command_internal() { _warp_execute_command "$@" & local pid=$! echo $pid >> $_WARP_GENERATOR_PIDS_STARTED_TMP_FILE wait $pid 2> /dev/null if [[ $? -ne 0 ]]; then warp_send_generator_output_osc "$1;;1" fi if [[ -f $_WARP_GENERATOR_PIDS_COMPLETED_TMP_FILE ]]; then echo $pid >> $_WARP_GENERATOR_PIDS_COMPLETED_TMP_FILE fi } warp_run_generator_command() { _WARP_GENERATOR_COMMAND=1 _USER_PRECMD_FUNCTIONS=($precmd_functions) precmd_functions=(${(M)precmd_functions:#*(warp|p9k)*}) (_warp_run_generator_command_internal "$@" &) } _is_warp_generator_command() { [[ "$1" != *"warp_run_generator_command"* ]] } warp_preexec () { local warp_escaped_command="$(warp_escape_json $1)" warp_send_json_message "{\"hook\": \"Preexec\", \"value\": {\"command\": \"$warp_escaped_command\"}}" warp_maybe_send_reset_grid_osc if _is_warp_generator_command "$1" && [[ -f $_WARP_GENERATOR_PIDS_STARTED_TMP_FILE ]] && [[ -f $_WARP_GENERATOR_PIDS_COMPLETED_TMP_FILE ]] then pids=($(command -p comm -23 $_WARP_GENERATOR_PIDS_STARTED_TMP_FILE $_WARP_GENERATOR_PIDS_COMPLETED_TMP_FILE)) if [[ ! -z $pids ]]; then (kill -9 $pids 2>&1) >/dev/null fi fi } warp_git () { GIT_OPTIONAL_LOCKS=0 command git "$@" } warp_precmd () { local exit_code=$? warp_send_json_message "{\"hook\": \"CommandFinished\", \"value\": {\"exit_code\": $exit_code, \"next_block_id\": \"precmd-$WARP_SESSION_ID-$((block_id++))\"}}" warp_maybe_send_reset_grid_osc if [ ! -z $_WARP_GENERATOR_COMMAND ]; then precmd_functions=($_USER_PRECMD_FUNCTIONS) unset _WARP_GENERATOR_COMMAND warp_send_json_message "{\"hook\": \"Precmd\", \"value\": { \"pwd\": \"\", \"ps1\": \"\", \"git_branch\": \"\", \"virtual_env\": \"\", \"conda_env\": \"\", \"session_id\": $WARP_SESSION_ID }}" return 0 fi if [[ -f $_WARP_GENERATOR_PIDS_STARTED_TMP_FILE ]]; then command -p rm $_WARP_GENERATOR_PIDS_STARTED_TMP_FILE 2>/dev/null fi if [[ -f $_WARP_GENERATOR_PIDS_COMPLETED_TMP_FILE ]]; then command -p rm $_WARP_GENERATOR_PIDS_COMPLETED_TMP_FILE 2>/dev/null fi _WARP_GENERATOR_PIDS_STARTED_TMP_FILE=$(command -p mktemp) _WARP_GENERATOR_PIDS_COMPLETED_TMP_FILE=$(command -p mktemp) bindkey -r '^P' bindkey '^P' kill-buffer bindkey -r '\ei' bindkey '\ei' warp_report_input bindkey -r '\ep' bindkey '\ep' warp_change_prompt_modes_to_ps1 bindkey -r '\ew' bindkey '\ew' warp_change_prompt_modes_to_warp_prompt local escaped_pwd if [ -n "$WSL_DISTRO_NAME" ]; then escaped_pwd=$(warp_escape_json "$(pwd -P)") else escaped_pwd=$(warp_escape_json "$PWD") fi local escaped_virtual_env="" local escaped_conda_env="" local escaped_git_branch="" local escaped_kube_config="" if [[ -n $WARP_BOOTSTRAPPED ]]; then if [[ -n $VIRTUAL_ENV ]]; then escaped_virtual_env=$(warp_escape_json $VIRTUAL_ENV) fi if [[ -n $CONDA_DEFAULT_ENV ]]; then escaped_conda_env=$(warp_escape_json $CONDA_DEFAULT_ENV) fi if [[ -n $KUBECONFIG ]]; then escaped_kube_config=$(warp_escape_json $KUBECONFIG) fi local git_branch if command -v git >/dev/null 2>&1; then git_branch=$(warp_git symbolic-ref --short HEAD 2> /dev/null || warp_git rev-parse --short HEAD 2> /dev/null) fi escaped_git_branch=$(warp_escape_json "$git_branch") fi local honor_ps1 if [[ "$WARP_HONOR_PS1" == "1" ]]; then honor_ps1="true" else honor_ps1="false" fi local escaped_json="{\"hook\": \"Precmd\", \"value\": { \"pwd\": \"$escaped_pwd\", \"ps1\": \"\", \"honor_ps1\": $honor_ps1, \"rprompt\": \"\", \"git_branch\": \"$escaped_git_branch\", \"virtual_env\": \"$escaped_virtual_env\", \"conda_env\": \"$escaped_conda_env\", \"kube_config\": \"$escaped_kube_config\", \"session_id\": $WARP_SESSION_ID }}" warp_send_json_message "$escaped_json" } warp_clear_on_next_block () { warp_send_json_message '{"hook": "ClearOnNextBlock"}' } warp_escape_json () { command -p sed -E 's/(["\\])/\\\1/g; s/'$'\b''/\\b/g; s/'$'\t''/\\t/g; s/'$'\f''/\\f/g; s/'$'\r''/\\r/g; $!s/$/\\n/' <<<"$*" | command -p tr -d '\n' } warp_escape_ps1 () { command -p tr '\n\n' ' ' <<< "$*" | command -p od -An -v -tx1 | command -p tr -d ' \n' } warp_hex_encode_string () { printf '%s' "$1" | command -p od -An -v -tx1 | command -p tr -d ' \n' } function warp_title { DISABLE_AUTO_TITLE="true" setopt localoptions nopromptsubst [[ -n "$INSIDE_EMACS" && "$INSIDE_EMACS" != vterm ]] && return title="%25<..<$1" # shorten the tab_title to 25 characters print -Pn "\e]0;${title:q}\a" # set tab & window name (they're the same in Warp) } ZSH_THEME_TERM_TITLE_IDLE="%~" ZSH_THEME_TERM_TAB_TITLE_IDLE_REMOTE="%m:%~" function warp_set_title_idle_on_precmd { [[ "${WARP_DISABLE_AUTO_TITLE:-}" != true ]] || return if [[ $WARP_IS_LOCAL_SHELL_SESSION == "1" ]]; then warp_title "$ZSH_THEME_TERM_TITLE_IDLE" else warp_title "$ZSH_THEME_TERM_TAB_TITLE_IDLE_REMOTE" fi } function warp_set_title_active_on_preexec { [[ "${WARP_DISABLE_AUTO_TITLE:-}" != true ]] || return emulate -L zsh setopt extended_glob local -a cmdargs cmdargs=("${(z)2}") if [[ "${cmdargs[1]}" = fg ]]; then local job_id jobspec="${cmdargs[2]#%}" case "$jobspec" in <->) # %number argument: job_id=${jobspec} ;; ""|%|+) # empty, %% or %+ argument: job_id=${(k)jobstates[(r)*:+:*]} ;; -) # %- argument: job_id=${(k)jobstates[(r)*:-:*]} ;; [?]*) # %?string argument: job_id=${(k)jobtexts[(r)*${(Q)jobspec}*]} ;; *) # %string argument: job_id=${(k)jobtexts[(r)${(Q)jobspec}*]} ;; esac if [[ -n "${jobtexts[$job_id]}" ]]; then 1="${jobtexts[$job_id]}" 2="${jobtexts[$job_id]}" fi fi local CMD="${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%}" local LINE="${2:gs/%/%%}" warp_title "$CMD" } function warp_report_input { local escaped_input="$(warp_escape_json "$BUFFER")" warp_send_json_message "{ \"hook\": \"InputBuffer\", \"value\": { \"buffer\": \"$escaped_input\" } }" BUFFER="" } zle -N warp_report_input function clear() { warp_send_json_message "{\"hook\": \"Clear\", \"value\": {}}" } function warp_finish_update { local update_id="$1" warp_send_json_message "{ \"hook\": \"FinishUpdate\", \"value\": { \"update_id\": \"$update_id\"} }" } function warp_handle_dist_upgrade { local source_file_name="$1" eval "$(command apt-config shell APT_SOURCESDIR 'Dir::Etc::sourceparts/d')" if [[ ! -e $APT_SOURCESDIR$source_file_name.list && \ ! -e $APT_SOURCESDIR$source_file_name.sources && \ -e $APT_SOURCESDIR$source_file_name.list.distUpgrade ]]; then sudo cp "$APT_SOURCESDIR$source_file_name.list.distUpgrade" "$APT_SOURCESDIR$source_file_name.list" fi } function warp_update_prompt_vars() { local prompt_prefix=$'\e]133;A\a' local rprompt_prefix=$'\e]133;P;k=r\a' local prompt_suffix=$'\e]133;B\a' if [[ "$WARP_HONOR_PS1" != "1" ]] && [ "$WARP_USING_WINDOWS_CON_PTY" = true ]; then local suffix="$prompt_suffix$OSC_RESET_GRID" else local suffix="$prompt_suffix" fi local prompt_prefix_with_cursor_marker="%{$prompt_prefix" local suffix_with_cursor_marker="$suffix%}" local prompt_prefix_with_cursor_marker_surrounded="%{$prompt_prefix%}" local suffix_with_cursor_marker_surrounded="%{$suffix%}" if [[ "$WARP_HONOR_PS1" != "1" ]]; then if [[ "$PROMPT" != "%{$prompt_prefix"*"%}" ]]; then SAVED_PROMPT=$PROMPT fi if [[ "$RPROMPT" != "%{$rprompt_prefix$suffix%}" ]]; then SAVED_RPROMPT=$RPROMPT fi unset RPROMPT fi if [[ -n "$PROMPT" ]]; then if [[ "$PROMPT" == *"$prompt_prefix_with_cursor_marker_surrounded"* ]]; then local preceding_prefix=${PROMPT%%$prompt_prefix_with_cursor_marker_surrounded*} local following_prefix=${PROMPT#*$prompt_prefix_with_cursor_marker_surrounded} PROMPT=$preceding_prefix$following_prefix fi if [[ "$PROMPT" == *"$suffix_with_cursor_marker_surrounded"* ]]; then local preceding_suffix=${PROMPT%$suffix_with_cursor_marker_surrounded*} local following_suffix=${PROMPT##*$suffix_with_cursor_marker_surrounded} PROMPT=$preceding_suffix$following_suffix fi if [[ "$PROMPT" == *"$prompt_prefix_with_cursor_marker"* ]]; then local preceding_prefix=${PROMPT%%$prompt_prefix_with_cursor_marker*} local following_prefix=${PROMPT#*$prompt_prefix_with_cursor_marker} PROMPT=$preceding_prefix$following_prefix fi if [[ "$PROMPT" == *"$suffix_with_cursor_marker"* ]]; then local preceding_suffix=${PROMPT%$suffix_with_cursor_marker*} local following_suffix=${PROMPT##*$suffix_with_cursor_marker} PROMPT=$preceding_suffix$following_suffix fi ORIGINAL_PROMPT=$PROMPT PROMPT="$prompt_prefix$PROMPT$suffix" fi if [[ -n "$RPROMPT" && "$RPROMPT" != *"$rprompt_prefix"* ]]; then ORIGINAL_RPROMPT=$RPROMPT RPROMPT="$rprompt_prefix$RPROMPT$suffix" fi if [[ "$WARP_HONOR_PS1" != "1" ]]; then if [[ "$PROMPT" != "%{$prompt_prefix$ORIGINAL_PROMPT$suffix%}" ]]; then PROMPT="%{$prompt_prefix$ORIGINAL_PROMPT$suffix%}" fi else if [[ "$PROMPT" != "%{"*"%}" ]]; then PROMPT="%{$prompt_prefix%}$ORIGINAL_PROMPT%{$suffix%}" fi fi if [[ "$RPROMPT" != "%{"*"%}" ]]; then RPROMPT="%{$RPROMPT%}" fi precmd_functions=("${(@)precmd_functions[@]:#warp_update_prompt_vars}") precmd_functions+=(warp_update_prompt_vars) } function warp_change_prompt_modes_to_ps1() { PROMPT="$SAVED_PROMPT" RPROMPT="$SAVED_RPROMPT" WARP_HONOR_PS1=1 warp_update_prompt_vars zle .reset-prompt } zle -N warp_change_prompt_modes_to_ps1 function warp_change_prompt_modes_to_warp_prompt() { WARP_HONOR_PS1=0 warp_update_prompt_vars zle .reset-prompt } zle -N warp_change_prompt_modes_to_warp_prompt if [[ $WARP_IS_LOCAL_SHELL_SESSION == "1" ]]; then function is_interactive_ssh_session() { ARGS=() # this array holds any positional arguments while [ $# -gt 0 ]; do OPTIND=1 while getopts :1246AaCfgKkMNnqsTtVvXxYyb:c:D:e:F:i:L:l:m:O:o:p:R:S:W:w: OPTION; do case $OPTION in T) return 1;; W) return 1;; \?) return 1;; :) return 1;; esac done [ $? -eq 0 ] || return 2 # getopts failed [ $OPTIND -gt $# ] && break # we reached the end of the parameters shift "$((OPTIND - 1))" # skip all options processed so far ARGS+=($1) # save first non-option argument (a.k.a. positional argument) shift # remove saved arg done if [[ ${#ARGS[@]} -ne 1 ]]; then return 1 fi } function warp_ssh_helper() { local zsh_env_script=$(printf '%s' 'unsetopt ZLE; unset RCS; unset GLOBAL_RCS; WARP_SESSION_ID="$(command -p date +%s)$RANDOM"; WARP_USING_WINDOWS_CON_PTY=false; _hostname=$(command -pv hostname >/dev/null 2>&1 && command -p hostname 2>/dev/null || command -p uname -n); _user=$(command -pv whoami >/dev/null 2>&1 && command -p whoami 2>/dev/null || echo $USER); _msg=$(printf "{\"hook\": \"InitShell\", \"value\": {\"session_id\": $WARP_SESSION_ID, \"shell\": \"zsh\", \"user\": \"%s\", \"hostname\": \"%s\"}}" "$_user" "$_hostname" | command -p od -An -v -tx1 | command -p tr -d '"'"' \n'"'"'); printf '"'"'\e]9278;d;%s\x07'"'"' $_msg; unset _hostname _user _msg' | command -p od -An -v -tx1 | command -p tr -d ' \n') command ssh -o ControlMaster=yes -o ControlPath=$SSH_SOCKET_DIR/$WARP_SESSION_ID \ -t "${@:1}" \ " export TERM_PROGRAM='WarpTerminal' hook="'$(printf "{\"hook\": \"SSH\", \"value\": {\"socket_path\": \"'$SSH_SOCKET_DIR/$WARP_SESSION_ID'\", \"remote_shell\": \"%s\"}}" "${SHELL##*/}" | command -p od -An -v -tx1 | command -p tr -d " \n")'" printf '$OSC_START$DCS_JSON_MARKER$OSC_PARAM_SEPARATOR%s$OSC_END' "'$hook'" if test "'"${SHELL##*/}" != "bash" -a "${SHELL##*/}" != "zsh"'"; then if test ! -e "'$HOME/.hushlogin'"; then if test -r /etc/motd; then command -p cat /etc/motd elif test -r /run/motd; then command -p cat /run/motd elif test -r /run/motd.dynamic; then command -p cat /run/motd.dynamic elif test -r /usr/lib/motd; then command -p cat /usr/lib/motd elif test -r /usr/lib/motd.dynamic; then command -p cat /usr/lib/motd.dynamic fi fi if test -r /etc/profile; then . /etc/profile fi exec "'$SHELL'" fi case "'${SHELL##*/}'" in bash) exec -a bash bash --rcfile <(echo '"' command -p stty raw HISTCONTROL=ignorespace HISTIGNORE=" *" WARP_SESSION_ID="$(command -p date +%s)$RANDOM" WARP_HONOR_PS1="'$WARP_HONOR_PS1'" _hostname=$(command -pv hostname >/dev/null 2>&1 && command -p hostname 2>/dev/null || command -p uname -n) _user=$(command -pv whoami >/dev/null 2>&1 && command -p whoami 2>/dev/null || echo $USER) _msg=$(printf "{\"hook\": \"InitShell\", \"value\": {\"session_id\": $WARP_SESSION_ID, \"shell\": \"bash\", \"user\": \"%s\", \"hostname\": \"%s\"}}" "$_user" "$_hostname" | command -p od -An -v -tx1 | command -p tr -d " \n")'" WARP_USING_WINDOWS_CON_PTY=false if [[ "'$OS'" == Windows_NT ]]; then WARP_IN_MSYS2=true; else WARP_IN_MSYS2=false; fi printf '\''"'\e]9278;d;%s\x07'"'\'' \""'$_msg'"\"' unset _hostname _user _msg ) ;; zsh) WARP_TMP_DIR="'$(command -p mktemp -d warptmp.XXXXXX)'" local ZSH_ENV_SCRIPT='$zsh_env_script' local WARP_HONOR_PS1='$WARP_HONOR_PS1' if [[ "'$?'" == 0 ]]; then if command -pv xxd >/dev/null 2>&1; then echo "'$ZSH_ENV_SCRIPT'" | command -p xxd -p -r > "'$WARP_TMP_DIR'"/.zshenv else for i in {0..\$((\${#ZSH_ENV_SCRIPT} - 1))..2}; do builtin printf "'"\x${ZSH_ENV_SCRIPT:$i:2}"'" done > "'$WARP_TMP_DIR'"/.zshenv fi else echo \"Failed to bootstrap warp. Continuing with a non-bootstrapped shell.\" fi TMPPREFIX="'$HOME/.zshtmp-'" WARP_SSH_RCFILES="'${ZDOTDIR:-$HOME}'" WARP_HONOR_PS1="'$WARP_HONOR_PS1'" ZDOTDIR="'$WARP_TMP_DIR'" exec -l zsh -g $TRACE_FLAG_IF_WARP_SHELL_DEBUG_MODE ;; esac " } function ssh() { if is_interactive_ssh_session "$@"; then warp_send_json_message "{\"hook\": \"PreInteractiveSSHSession\", \"value\": {}}" if [ "$WARP_USE_SSH_WRAPPER" = "1" ]; then local TRACE_FLAG_IF_WARP_SHELL_DEBUG_MODE="" if [[ "$WARP_SHELL_DEBUG_MODE" == "1" ]]; then TRACE_FLAG_IF_WARP_SHELL_DEBUG_MODE="-x" fi warp_ssh_helper "$@" else command ssh "$@" fi else command ssh "$@" fi } fi warp_precmd if [[ -o login && ! -e "$HOME/.hushlogin" ]]; then for motd_file in /etc/motd /run/motd /run/motd.dynamic /usr/lib/motd /usr/lib/motd.dynamic; do if [[ -r "$motd_file" ]]; then command -p cat "$motd_file" break fi done fi setopt ZLE typeset -g POWERLEVEL9K_INSTANT_PROMPT=off precmd_functions+=(warp_set_title_idle_on_precmd) preexec_functions+=(warp_set_title_active_on_preexec) TEMPLATE_PREFIX="warptmp." if [[ -n $ZDOTDIR ]]; then if [[ ${ZDOTDIR:0:${#TEMPLATE_PREFIX}} == $TEMPLATE_PREFIX ]]; then command -p rm -r "$ZDOTDIR" ZDOTDIR=$WARP_SSH_RCFILES fi fi zmodload -F zsh/datetime +p:EPOCHREALTIME >/dev/null 2>&1 local rcfiles_start_time="$(LC_ALL="C"; echo $EPOCHREALTIME)" if [[ -z $WARP_IS_SUBSHELL ]]; then if [[ -e ${ZDOTDIR:-$HOME}/.zshenv ]]; then source ${ZDOTDIR:-$HOME}/.zshenv; fi if [[ -e /etc/zprofile ]]; then source /etc/zprofile; fi if [[ -e ${ZDOTDIR:-$HOME}/.zprofile ]]; then source ${ZDOTDIR:-$HOME}/.zprofile; fi if [[ -e /etc/zshrc ]]; then source /etc/zshrc; fi if [[ -e ${ZDOTDIR:-$HOME}/.zshrc ]]; then source ${ZDOTDIR:-$HOME}/.zshrc; fi if [[ -e /etc/zlogin ]]; then source /etc/zlogin; fi if [[ -e ${ZDOTDIR:-$HOME}/.zlogin ]]; then source ${ZDOTDIR:-$HOME}/.zlogin; fi fi local rcfiles_end_time="$(LC_ALL="C"; echo $EPOCHREALTIME)" if [[ $POWERLEVEL9K_PROMPT_ADD_NEWLINE == true ]]; then POWERLEVEL9K_PROMPT_ADD_NEWLINE=false fi _warp_zshaddhistory() { _is_warp_generator_command "$1" } zshaddhistory_functions+=(_warp_zshaddhistory) local -a shell_plugins if [[ ${precmd_functions[(I)_p9k_precmd]} != 0 ]]; then if [[ -z "$P9K_VERSION" ]]; then precmd_functions=(${precmd_functions:#_p9k_precmd}) shell_plugins+=(p10k_unsupported) else shell_plugins+=(p10k) fi fi if [[ ${precmd_functions[(I)prompt_pure_precmd]} != 0 ]]; then precmd_functions=(${precmd_functions:#prompt_pure_precmd}) shell_plugins+=(pure) fi shell_options="$(setopt)" for i in ${(f)shell_options}; do if [[ "$i" == "vi" ]]; then vi_mode_in_opts=1 fi done NVIM_RE='([[:space:]]|^)nvim([[:space:]]|$)' ZLE_BINDKEY="$(bindkey -lL main)" if [[ -n "$vi_mode_in_opts" ]]; then shell_plugins+=(vi) elif [[ "$EDITOR" =~ "$NVIM_RE" ]] || [[ "$VISUAL" =~ "$NVIM_RE" ]]; then shell_plugins+=(vi) elif [[ "$ZLE_BINDKEY" = *viins* ]] || [[ "$ZLE_BINDKEY" = *vicmd* ]]; then shell_plugins+=(vi) elif [[ ${precmd_functions[(I)zvm_init]} != 0 ]]; then shell_plugins+=(vi) fi if kernel_name="$(uname)"; then if [[ "$kernel_name" == "Darwin" ]]; then os_category="MacOS" elif [[ "$kernel_name" == "Linux" ]]; then os_category="Linux" default_os_release_filepath="/etc/os-release" fallback_os_release_filepath="/usr/lib/os-release" if test -f "$default_os_release_filepath"; then os_release_file="$default_os_release_filepath" elif test -f "$fallback_os_release_filepath"; then os_release_file="$fallback_os_release_filepath" fi if test -f "$os_release_file"; then linux_distribution="$(cat $os_release_file | sed -nE 's/^NAME="(.*)"$/\1/p')" fi fi fi precmd_functions+=(warp_precmd warp_update_prompt_vars) preexec_functions+=(warp_preexec) WARP_BOOTSTRAPPED=1 export CONDA_CHANGEPS1=false warp_update_prompt_vars setopt share_history function compadd () { if [[ -z "${COMPADD_OVERRIDE}" || "${COMPADD_OVERRIDE}" == "false" || ${@[1,(i)(-|--)]} == *-(O|A|D)\ * ]]; then builtin compadd "$@" return $? fi typeset -a __hits __dscr __tmp if (( $@[(I)-d] )); then # kind of a hack, $+@[(r)-d] doesn''t work because of line noise overload __tmp=${@[$[${@[(i)-d]}+1]]} if [[ $__tmp == \(* ]]; then eval "__dscr=$__tmp" else __dscr=( "${(@P)__tmp}" ) fi fi builtin compadd -A __hits -D __dscr "$@" setopt localoptions norcexpandparam extendedglob typeset -A apre hpre hsuf asuf zparseopts -E -a extra_args - f=dirsuf P:=apre p:=hpre S:=asuf s:=hsuf a k q Q e n U l 1 2 C integer dirsuf=${#dirsuf} [[ -n $__hits ]] || return local dsuf dscr for i in {1..$#__hits}; do (( dirsuf )) && [[ -d $__hits[$i] ]] && dsuf=/ || dsuf= (( $#__dscr >= $i )) && dscr="${${__dscr[$i]}##$__hits[$i] #}" || dscr="" local match="$__hits[$i]$dsuf" print -n "\e]9280;C"$OSC_PARAM_SEPARATOR$match$OSC_END print -n "\e]9280;D?description"$OSC_PARAM_SEPARATOR$dscr$OSC_END done } function warp_mark_start_of_completions () { printf '\e]9280;A;%s\a' $1 } function warp_mark_start_of_completions_for_list_choices () { warp_mark_start_of_completions 'raw' } function warp_mark_start_of_completions_for_compadd_override () { warp_mark_start_of_completions 'incrementally_typed' } function warp_mark_end_of_completions () { printf '\e]9280;B\a' } function warp_main_completer () { compstate[list_max]=-1 COLUMNS=500 _generic } function warp_complete_via_list_choices () { zle warp_read_completion_buffer unsetopt ALWAYS_LAST_PROMPT compprefuncs=( warp_mark_start_of_completions_for_list_choices ) zle warp_complete_via_list_choices_internal BUFFER="" } function warp_complete_via_compadd_override () { zle warp_read_completion_buffer compprefuncs=( warp_mark_start_of_completions_for_compadd_override ) comppostfuncs=( warp_mark_end_of_completions ) COMPADD_OVERRIDE=true zle warp_complete_via_compadd_override_internal BUFFER="" unset COMPADD_OVERRIDE } function warp_read_completion_buffer() { local TEMP IFS= read -d $'\4' -s "$(echo -e "TEMP?\e]9280;P\a")" < /dev/tty BUFFER="$TEMP" echo -n "${DCS_START}a" zle push-line zle get-line echo -n "$DCS_END" } zle -N warp_read_completion_buffer zle -C warp_complete_via_list_choices_internal list-choices warp_main_completer zle -C warp_complete_via_compadd_override_internal list-choices warp_main_completer zle -N warp_complete_via_list_choices zle -N warp_complete_via_compadd_override bindkey '^X' warp_complete_via_list_choices bindkey '^Y' warp_complete_via_compadd_override zstyle ':completion:warp_complete_via_list_choices:*' verbose no zstyle ':completion:warp_complete_via_list_choices:*' list-packed yes zstyle ':completion:warp_complete_via_list_choices:*' list-rows-first yes zstyle ':completion:warp_complete_via_list_choices:*' list-prompt '' zstyle ':completion:warp_complete_via_compadd_override:*' list-grouped false zstyle ':completion:warp_complete_via_compadd_override:*' insert-tab false zstyle ':completion:warp_complete_via_compadd_override:*' verbose yes zstyle ':completion:warp_complete_via_compadd_override:*' list-separator '' function warp_bootstrapped () { local escaped_histfile="$(warp_escape_json $HISTFILE)" local escaped_aliases="$(warp_escape_json "alias")" local escaped_abbrs="" local env_var_names="$(warp_escape_json "echo ${(k)parameters[(R)export]}")" local function_names="$(warp_escape_json "builtin print -l -- ${(ok)functions}")" local escaped_builtins="$(warp_escape_json "builtin print -l -- ${(ok)builtins}")" local escaped_keywords="$(warp_escape_json "builtin print -l -- ${(ok)reswords}")" local escaped_path="$(warp_escape_json "$PATH")" local escaped_shell_plugins="$(warp_escape_json "builtin print -l -- ${shell_plugins}")" local shell_options="$(warp_escape_json "setopt")" local escaped_json="{\"hook\": \"Bootstrapped\", \"value\": {\"histfile\": \"$escaped_histfile\", \"shell\": \"zsh\", \"home_dir\": \"$HOME\", \"path\": \"$escaped_path\", \"env_var_names\": \"$env_var_names\", \"abbreviations\": \"$escaped_abbrs\", \"aliases\": \"$escaped_aliases\", \"function_names\": \"$function_names\", \"builtins\": \"$escaped_builtins\", \"keywords\": \"$escaped_keywords\", \"shell_version\": \"$ZSH_VERSION\", \"shell_options\": \"$shell_options\", \"rcfiles_start_time\": \"$rcfiles_start_time\", \"rcfiles_end_time\": \"$rcfiles_end_time\", \"shell_plugins\": \"$escaped_shell_plugins\", \"os_category\": \"$os_category\", \"linux_distribution\": \"$linux_distribution\", \"wsl_name\": \"$WSL_DISTRO_NAME\"}}" warp_send_json_message "$escaped_json" } warp_bootstrapped fi EOM

To reproduce

  1. Do some work in a tab.
  2. Open up a new tab and quickly press the up arrow.
  3. Initialization bash script appears in Warp

Expected behavior

Expect to see the last command and suggestions (this happens after waiting slightly longer before pressing up arrow)

Screenshots, videos, and logs

No response

Operating system (OS)

macOS

Operating system and version

Mac 15.5 (24F74)

Shell Version

GNU bash, version 3.2.57(1)-release (arm64-apple-darwin24)

Current Warp version

v0.2025.06.11.08.11.stable_01

Regression

No, this bug or issue has existed throughout my experience using Warp

Recent working Warp date

No response

Additional context

No response

Does this block you from using Warp daily?

No

Is this an issue only in Warp?

Yes, I confirmed that this only happens in Warp, not other terminals.

Warp Internal (ignore): linear-label:b9d78064-c89e-4973-b153-5178a31ee54e

None