PROMPT="%{$fgbold[blue]%}%n@%m%{$resetcolor%} [%{$fg_bold[cyan]%}%~%{$reset_color%}]" 这是…
- User
PROMPT="%{reset_color%} [%{reset_color%}]" 这是 linux oh-my-zsh 主题的一行自定义设置,我需要把 blue 换成一个 自定义颜色 #94CEE7 怎么设置
Assistant
Oh-my-zsh 使用的是 Zsh 的扩展功能来处理颜色,它原生不支持直接使用十六进制颜色代码。但是,你可以使用 ANSI escape codes 来设置自定义颜色。
为了使用自定义颜色
#94CEE7,你需要先转换它到 ANSI escape code。下面是如何在 PROMPT 中设置自定义颜色的方法:bashPROMPT="%{$fg_bold[${(l:6::2::#94CEE7)}]%}%n@%m%{$reset_color%} [%{$fg_bold[cyan]%}%~%{$reset_color%}]"但是,上述方法在 oh-my-zsh 中可能不会直接工作,因为
$(l:6::2::#94CEE7)这种格式不是 oh-my-zsh 或 zsh 支持的直接方式。以下是如何正确设置自定义颜色的步骤:
- 首先,你需要将十六进制颜色转换为 ANSI escape code。
- 然后,你需要使用这个 ANSI code 在你的 PROMPT 中。
以下是修改后的代码:
bash# Convert hex color to ANSI escape code zmodload zsh/parameter typeset -AHg FX FX=( reset "%{[00m%}" bold "%{[01m%}" # ... other effects # Add your custom color here custom "%{[38;5;$(print -Pn "$(( 16#$1 / 65536 * 36 + 16#$1 % 65536 / 256 * 6 + 16#$1 % 256 / 1 ))")m%}" ) # Now use the custom color in your prompt PROMPT="%{$FX[bold]$FX[custom=\"#94CEE7\"]%}%n@%m%{$reset_color%} [%{$fg_bold[cyan]%}%~%{$reset_color%}]"
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.