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

如何移除fish shell终端右侧时间戳并自定义该元素

Hey there! Let’s sort out your fish shell timestamp needs — first removing that right-side timestamp, then customizing it to match your desired style.

移除右侧时间戳

Fish shell’s right-side prompt is controlled by the fish_right_prompt function. Here’s how to ditch the timestamp:

  • Open the function editor for the right prompt:
    funced fish_right_prompt
    
  • Look for any lines that generate the timestamp — they’ll usually involve date or a pre-defined timestamp variable. Delete those lines entirely.
  • Save your changes to make them permanent:
    funcsave fish_right_prompt
    
  • Either restart your terminal or run source ~/.config/fish/config.fish to apply the changes immediately.

If you’re using a fish theme (like Oh My Fish’s bobthefish), check the theme’s configuration first — many themes have a toggle for the right prompt timestamp (e.g., set -g theme_show_right_prompt no for bobthefish).

自定义时间戳为目标样式

Let’s build a custom timestamp that matches your desired look (we’ll use a common styled example, which you can tweak further):

  • Reopen the right prompt editor:
    funced fish_right_prompt
    
  • Replace the existing content (or add this if starting fresh) with code that defines your custom timestamp. For example, this creates a bracketed, gray-background white-text timestamp:
    # Custom timestamp: gray background, white text, [HH:MM:SS] format
    echo -n (set_color -b brblack white) "["(date '+%H:%M:%S')"]"(set_color normal)
    
    Quick breakdown:
    • set_color -b brblack white: Sets a soft gray background and white text for the timestamp
    • date '+%H:%M:%S': Generates time in 24-hour format (adjust to '%I:%M %p' for 12-hour AM/PM, or '%Y-%m-%d %H:%M' to add the date)
    • (set_color normal): Resets colors back to your terminal’s default after the timestamp
  • Save the function:
    funcsave fish_right_prompt
    
  • Test it out by running any command — your new styled timestamp should appear on the right side instantly!

Tweak the set_color arguments or date format string to match your exact desired style.

内容的提问来源于stack exchange,提问作者mickkk

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 10:43:32