warpdotdev / Warp

Warp is a modern, Rust-based terminal with AI built in so you and your team can build great software, faster.
https://warp.dev
Other
21.13k stars 362 forks source link

Right sided prompts - ZSH prompt having a time widget at the right edge misbehaves in Warp #936

Open miohtama opened 2 years ago

miohtama commented 2 years ago

Discord username (optional)

No response

Describe the bug

If you have a ZSH prompt that sets the prompt widget to the right edge of the screen (RPROMPT) Warp gets confused. The block editor does not start the text edit cursor on a new line, but at the right edge of the screen. Then it sets the clock text as the text that appears on the command line.

About RPROMPT.

To Reproduce

Steps to reproduce:

  1. MacOS
  2. Create .zshrc file with the following content
ZSH_THEME_GIT_PROMPT_PREFIX="[%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%}✗%{$fg[white]%}]"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[white]%}]"

function git_prompt_info() {
  ref=$(git symbolic-ref HEAD 2> /dev/null) || \
  ref=$(git rev-parse --short HEAD 2> /dev/null) || return
  echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
}

PROMPT_HOSTNAME=`hostname`

IMAGE_NAME=""

if [[ -e /etc/issue ]] 
then
    IMAGE_NAME="`grep 'Image:' /etc/issue|sed 's/Image: *\([^ ]\+\).*/\1/'`"
fi

function setup_prompt {
    RPROMPT=`echo -ne "%{\033[A%}%B[%{\033[${PROMPT_USER_COLOR:-1;33}m%}%n%{\033[0m%}%B@%{\033[${PROMPT_HOST_COLOR:-1;33}m%}$PROMPT_HOSTNAME%b%B][%{\033[1;32m%}%T%b%B]%{\033[B%}"`
    PROMPT=`echo -ne '%B$(git_prompt_info)\n%{\033[0m%}%B[%{\033[36m%}%~%b%B]%#'`" "
}

if [[ -x /usr/bin/hostname-filter ]]
then
    PROMPT_HOSTNAME=`/usr/bin/hostname-filter`
fi

setup_prompt
  1. Open Wrap with zsh set as the user default shell
  2. Prompt autofills the current time as the prompt test when you press enter

Note that this does not to seem to happen if you do this on a remote server, or you open a new shell within the existing zsh session. But in this case, the block editing does not work either.

zsh -f -d   # Start clean shell, no env vars set
source .zshrc  # Set prompt

Expected behaviour

Warp editor would render the prompt as any other terminal does. I added iTerm 2 as an example.

Screenshots

Warp (see how it picks the clock text as the command at the first block):

image

iTerm:

image

Operating System

MacOS

OS Version

Big Sur

Additional context

No response

miohtama commented 2 years ago

The workaround is not to set RPROMPT if we detect Warp the terminal:

    # Work around Warp terminal issues
    # https://github.com/warpdotdev/Warp/issues/936
    if [[ "$WARP_USE_SSH_WRAPPER" == "" ]] ; then
        RPROMPT=`echo -ne "%{\033[A%}%B[%{\033[${PROMPT_USER_COLOR:-1;33}m%}%n%{\033[0m%}%B@%{\033[${PROMPT_HOST_COLOR:-1;33}m%}$PROMPT_HOSTNAME%b%B][%{\033[1;32m%}%T%b%B]%{\033[B%}"`
    fi    
craig-ezyvet commented 2 years ago

Alternatively hit ctrl+c and it will move to the correct position if its in the RPROMPT area but not ideal to do after every command

elviskahoro commented 2 years ago

Sorry for this folks! We still have trouble with right sided prompts!

elviskahoro commented 2 years ago

From @KieranP via #846

Describe the bug

When I try to use starship right prompt setting, it doesn't display. Instead, Warp is adding a strange invisible character at the start of the second line.

To Reproduce

Install starship and configure with:

format = "$directory$git_branch$git_metrics$git_status"
right_format = "$ruby$nodejs"

Expected behaviour

Ruby and Node info would be on the right side of the prompt

Screenshots

No response

Operating System

MacOS

OS Version

12.3

Additional context

No response

elviskahoro commented 2 years ago

From @sullimander via #838

Describe the bug

I have a `fish_right_prompt` setup. In other terminals, the right prompt appears to the right of the main `fish_prompt` and the input is between them. In Warp, the `fish_right_prompt` only appears after hitting enter on a command.

To Reproduce

Steps to reproduce:

Create a functions/fish_prompt.fish file with something similar to the following:

function fish_prompt
  set last_status $status
  set_color yellow
  echo -n "("(git config user.email)")"
  set_color cyan
  echo -n "("(prompt_pwd)")"

  # Print command duration
  if test $CMD_DURATION; and test $CMD_DURATION != 0
    set duration $CMD_DURATION

    set_color green

    # Show duration of the last command in seconds
    if test $CMD_DURATION -gt 1000
      set_color yellow
      set duration (echo "$duration 1000" | awk '{printf "%.3fs", $1 / $2}')
    end

    if test $CMD_DURATION -gt 10000
      set_color red
    end

    echo -n "($duration)"
  end

  set_color red
  switch $last_status
  case 0
    set_color green
  end
  echo -n "\$ "
  set_color normal
end

Create a functions/fish_right_prompt.fish with something similar to the following

function fish_right_prompt
  # Git prompt
  set_color green
  fish_git_prompt

  # rbenv version
  set_color cyan
  echo -n "("(rbenv version-name)")"

  # vim mode indicator
  switch $fish_bind_mode
    case default
      set_color red
      echo -n '(N)'
    case insert
      set_color yellow
      echo -n '(I)'
    case replace_one
      set_color yellow
      echo -n '(R)'
    case visual
      set_color brmagenta
      echo -n '(V)'
    case '*'
      set_color red
      echo -n '(?)'
  end
end

Compare to the screenshots in this ticket

Expected behaviour

The `fish_right_prompt` should appear on the right side of the prompt line.

Screenshots

fish_right_prompt on Warp (v0.2022.03.23.22.10.stable_01)

warp-fish-right

fish_right_prompt on iTerm 2 (Build 3.5.0beta5)

iterm-fish-right

Operating System

MacOS

OS Version

12.3

Additional context

No response

elviskahoro commented 2 years ago

From @rcousens via #1159

Discord username (optional)

No response

Describe the bug

Launch warp, using tide prompt and fisher with fish shell. I have a right side as part of my prompt that for whatever reason is not overridden by warp. Regardless, it shows what it normally does in fish, however it is "stuck in time". I.e. the time never updates.

My preference would be if you're going to override the prompt then clear out the right side prompt for fish (fish_right_prompt, see https://fishshell.com/docs/current/cmds/fish_right_prompt.html)

To Reproduce

Open warp

Expected behaviour

No response

Screenshots

Screen Shot 2022-04-22 at 8 37 29 pm

Operating System

MacOS

OS Version

12.3.1

Additional context

No response

statusunknown418 commented 2 years ago

zsh takes too long to start in warp has anyone seen this error or knows how to solve it? I recently switch to warp from zsh+fig and it's giving me a bit of trouble.

.zshrc

# Fig pre block. Keep at the top of this file.
[[ -f "$HOME/.fig/shell/zshrc.pre.zsh" ]] && builtin source "$HOME/.fig/shell/zshrc.pre.zsh"
eval $(thefuck --alias)

alias ll="exa --icons --group-directories-first --all --long --no-user"
alias l="exa --icons --group-directories-first --all --long --no-user"

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

# bun completions
[ -s "/Users/a3tech/.bun/_bun" ] && source "/Users/a3tech/.bun/_bun"

# Bun
export BUN_INSTALL="/Users/a3tech/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"

# pnpm
export PNPM_HOME="/Users/a3tech/Library/pnpm"
export PATH="$PNPM_HOME:$PATH"
# pnpm end

# EdgeDB
fpath+=~/.zfunc

# Poetry stuff
export PATH="/Users/a3tech/Library/Python/3.10/bin:$PATH"

# Starship prompt
eval "$(starship init zsh)"

# Fig post block. Keep at the bottom of this file.
[[ -f "$HOME/.fig/shell/zshrc.post.zsh" ]] && builtin source "$HOME/.fig/shell/zshrc.post.zsh"
warpdotdev-devx commented 2 years ago

I would say disable everything that isn't an alias or export, especially the completions: Fig, NVM:

You can also disable parts of your dotfiles just for Warp by using this conditional statement:

if [[ $TERM_PROGRAM != "WarpTerminal" ]]; then
##### WHAT YOU WANT TO DISABLE FOR WARP - BELOW

# Whatever you want to disable

##### WHAT YOU WANT TO DISABLE FOR WARP - ABOVE
fi

See our documentation here: https://docs.warp.dev/help/known-issues#debugging

--- original message --- On September 30, 2022 at 10:38 AM EDT @.*** wrote:

zsh takes too long to start in warp has anyone seen this error or knows how to solve it? I recently switch to warp from zsh+fig and it's giving me a bit of trouble.

.zshrc

Fig pre block. Keep at the top of this file.

[[ -f "$HOME/.fig/shell/zshrc.pre.zsh" ]] && builtin source "$HOME/.fig/shell/zshrc.pre.zsh" eval $(thefuck --alias)

alias ll="exa --icons --group-directories-first --all --long --no-user" alias l="exa --icons --group-directories-first --all --long --no-user"

export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion

bun completions

[ -s "/Users/a3tech/.bun/_bun" ] && source "/Users/a3tech/.bun/_bun"

Bun

export BUN_INSTALL="/Users/a3tech/.bun" export PATH="$BUN_INSTALL/bin:$PATH"

pnpm

export PNPM_HOME="/Users/a3tech/Library/pnpm" export PATH="$PNPM_HOME:$PATH"

pnpm end

EdgeDB

fpath+=~/.zfunc

Poetry stuff

export PATH="/Users/a3tech/Library/Python/3.10/bin:$PATH"

Starship prompt

eval "$(starship init zsh)"

Fig post block. Keep at the bottom of this file.

[[ -f "$HOME/.fig/shell/zshrc.post.zsh" ]] && builtin source "$HOME/.fig/shell/zshrc.post.zsh"

Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- You received this message because you are subscribed to the Google Groups "github" group. To unsubscribe from this group and stop receiving emails from it, send an email to @.*** --- end of original message ---

hajnalben commented 1 year ago

I am using Oh My Zsh and switching to the default theme solved the issue.

if [[ $TERM_PROGRAM != "WarpTerminal" ]]; then
  ZSH_THEME="avit"
else
  ZSH_THEME="robbyrussell"
fi
vorporeal commented 1 year ago

Hey all - a fix for this will be going live in this week's release. Sorry for the issues!

verdel commented 1 year ago

Is there any news about the fix?

vorporeal commented 1 year ago

A fix for the issue was submitted back in November; can you give more details about what you are experiencing?

It would be helpful if you could provide:

  1. What zsh theme you're using (e.g.: p10k, starship, some oh-my-zsh theme, etc.),
  2. A screenshot or video of what you're seeing.