You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:VSCode集成终端每行前出现奇怪%符号如何移除

Fix the Leading "%" in VSCode Integrated Terminal with Babun Zsh

Hey there! That annoying leading "%" on every line is usually tied to zsh's prompt configuration or a terminal type mismatch between VSCode and Babun. Let’s work through the fixes step by step:

1. Adjust Your Zsh Prompt Settings

The "%" character is likely coming from zsh’s default prompt variable (PS1 or PROMPT). Here’s how to tweak it:

  • Open Babun’s standalone terminal (not the VSCode integrated one) and run this command to check your current prompt setup:
    echo $PS1
    
  • Next, open your zsh config file for editing:
    nano ~/.zshrc
    
  • Look for lines that set PS1 or PROMPT. You might see something like this:
    PROMPT='%{%f%b%k%}%{%(?.%F{green}√.%F{red}?%?)%f%} %{%F{240}%}%~%{%f%} %{%F{green}%}%#%{%f%} '
    
  • The %# in that line outputs "%" for regular users (it shows "#" for root). To replace it with a "$" (or remove it entirely), modify the line to:
    PROMPT='%{%f%b%k%}%{%(?.%F{green}√.%F{red}?%?)%f%} %{%F{240}%}%~%{%f%} %{%F{green}%}$%{%f%} '
    
  • Save the file (in nano: press Ctrl+O, hit Enter, then Ctrl+X), then restart your VSCode integrated terminal.

2. Set the Correct Terminal Type in VSCode

Sometimes VSCode’s terminal doesn’t report the right terminal type to zsh, causing prompt glitches. Fix this by adding an environment variable in VSCode settings:

  • Open VSCode’s settings (File > Preferences > Settings, or press Ctrl+,).
  • Search for terminal.integrated.env.windows and click "Edit in settings.json".
  • Add this inside the JSON object:
    "terminal.integrated.env.windows": {
        "TERM": "xterm-256color"
    }
    
  • Save the settings and restart the integrated terminal.

3. Disable Babun’s Default Prompt Overrides (If Needed)

Babun comes with its own prompt configuration that might conflict in VSCode. To check this:

  • Open Babun’s config file in the standalone terminal:
    nano ~/.babunrc
    
  • Look for any lines that modify PS1 or PROMPT. If you find them, comment them out by adding a # at the start of the line.
  • Save the file and restart VSCode’s terminal.

After trying these steps, that pesky "%" should disappear from your terminal lines!

内容的提问来源于stack exchange,提问作者jihad.khorfan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 11:13:06