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

如何去除Starship提示符中的多余换行符?

解决Starship提示符多余换行问题
  • 错误原因分析:

    • add_newline是Starship的全局配置项,不能放在[username]模块下,这就是报错的核心原因。
    • 你的[character]模块format使用了多行字符串,其中包含的换行符会直接导致提示符出现空行。
  • 修改后的配置:
    将add_newline = false放在配置文件最顶部的全局区域,同时把character的format改为单行:

    add_newline = false
    
    [character]
    format = "[ ─>](bold green)"
    
    [username]
    style_user = "green bold"
    style_root = "black bold"
    format = "[$user]($style)@[Kyurem]($style) [$path]($style)"
    disabled = false
    show_always = true
    
    [directory]
    format = "[$path]($style)[$read_only]($read_only_style) "
    style = "bold #f57800"
    
    [git_status]
    disabled = true
    
  • 额外说明:

    • 全局add_newline用于控制Starship在提示符前是否添加空行,设为false即可去除多余换行。
    • 多行字符串的换行会被解析为实际换行符,因此character的format必须改为单行才能避免额外空行。

内容的提问来源于stack exchange,提问作者johannes-el

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.17 04:07:01