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
20.74k stars 347 forks source link

`cd` override for nvmrc shows up in git prompt #3703

Open chadoh opened 11 months ago

chadoh commented 11 months ago

Discord username (optional)

chadoh

Describe the bug

I have this little script that gets loaded as part of my .zprofile:

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

# auto-switch to node version specified in `.nvmrc`
load-nvmrc() {
  local nvmrc_path="$(nvm_find_nvmrc)"

  if [ -n "$nvmrc_path" ]; then
    local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")

    if [ "$nvmrc_node_version" = "N/A" ]; then
      nvm install
    elif [ "$nvmrc_node_version" != "$(nvm version)" ]; then
      nvm use
    fi
  elif [ -n "$(PWD=$OLDPWD nvm_find_nvmrc)" ] && [ "$(nvm version)" != "$(nvm version default)" ]; then
    echo "Reverting to nvm default version"
    nvm use default
  fi
}
autoload -Uz add-zsh-hook
add-zsh-hook chpwd load-nvmrc
load-nvmrc

Sometimes this ends up making my Warp prompt look like this:

image

To reproduce

Probably:

  1. use zsh
  2. add the script above to your .zprofile
  3. cd into a directory with a .nvmrc file, especially one that is malformatted (such as having a >= range, rather than just a specific version number)

Expected behavior

git prompt should just be git info

Screenshots

see above

Operating system

MacOS

Operating system and version

Ventura 13.5.2 (22G91)

Shell Version

zsh 5.9 (x86_64-apple-darwin22.0)

Current Warp version

v0.2023.09.19.08.04.stable_00

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 a Warp specific issue? (i.e. does it happen in Terminal, iTerm, Kitty, etc.)

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

Warp Internal (ignore): linear-label:b8107fdf-ba31-488d-b103-d271c89cac3e

None

dannyneira commented 11 months ago

Thanks for letting us know @chadoh, please provide an example of your .nvmrc file to help us reproduce the issue. We'll post any updates on this thread. As a workaround, please try a supported custom prompt.

To anyone else facing this issue, please add a :+1: to the original post at the top or comment with your details, and subscribe if you'd like to be notified.