自定义一个oh-my-zsh 主题

虽然OMZ有很多的主题可以选择,但是总是有的地方不是很满意,所以想要自己定义一个主题,但是百度发现居然没有一篇文章介绍这个。所以Google了一下怎么自己创建一个主题。

主题的位置是在~/.oh-my-zsh/themes/这个文件夹中。 所以在这个文件夹中创建一个文件,并修改~/.zshrc配置文件中的ZSH_THEME=字段, 将这个字段该为你创建的主题文件的文件名就可以了。

现在来说一下主题文件中该怎么写:
首先最基础的两行是:

# 左边的内容
PROMPT=’‘
# 右边的内容
RPROMPT=’’

PROMPT是显示在左边的内容,RPROMPT是显示在右边的内容

Prompting

偷个懒,复制一下别人写的 [原文]

%n - username
%m - short name of the current host
%M - name of curent host
%# - a `%` or a `#`, depending on whether the shell is running as root or not
%~ - relative path
%/ or %d - absolute path
%c or %C - Trailing component of the current working directory.
%t - time 12hr am/pm format
%T - time 24hr format
%w - day and date (day-dd)
%D - Date (default: yy-mm-dd)
%D{%f} - day of the month
%l or %y - The line  (tty)  the user is logged in on, without `/dev/' prefix.

例如 如果想在左边显用户和时间

PROMPT=’%n %t‘

然后是颜色:

字体颜色有几种写法:

  • %F{237} 256 color number
  • %F{red} 8 color name (black, red, green, yellow, blue, magenta, cyan, white)
  • $FG[237] (notice the $ sign instead of %) 256 color number
  • $fg[red] (notice the $ and lower case fg) 8 color name (black, red, green, yellow, blue, magenta, cyan, white)
  • %{$fg_bold[blue]%} bold variants
  • %F is Foreground color, $f for resetting foreground color
    %K is bacKground color, %k for resetting background-color
    $reset_color is a Zsh variable that resets the color of the output
    You can use Unicode for symbols
    %E Clear to end of the line.
    %U (%u) to Start (stop) underline mode.

你可以用下面的命令来检查一下样式:

print -P '%F{237} %m %f'

下面是OMZ默认主题的代码

PROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'

有空再来补充

  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
oh-my-zsh一个开源的、社区驱动的 zsh 配置管理框架,它提供了一系列的插件、主题自定义选项,使得用户可以轻松地定制和管理自己的 zsh 终端环境。它旨在提供一个更强大、更易用的终端工具。 而 oh-my-zsh-git 是 oh-my-zsh 在 GitHub 上的一个 fork 版本,它基于原版的 oh-my-zsh,对其进行了一些修改和扩展。oh-my-zsh-git 主要的目的是为了扩展和增强原版 oh-my-zsh 的功能,并从社区中收集和整合更多的插件和主题。 具体来说,oh-my-zsh-git 与 oh-my-zsh 的区别主要体现在以下几个方面: 1. 功能扩展:oh-my-zsh-git 在原版 oh-my-zsh 的基础上增加了一些功能和工具,使得终端使用起来更加方便和高效。 2. 插件和主题oh-my-zsh-git 提供了更多的插件和主题选项,且会持续更新和增加。用户可以根据自己的需求选择和使用不同的插件和主题。 3. 扩展性:oh-my-zsh-git 更加注重可扩展性,用户可以自定义添加新的插件和主题,或者根据自己的需要修改现有的插件和主题。 4. 社区支持:oh-my-zsh-git 的社区活跃度较高,用户能够得到更多的帮助和支持,同时也能够贡献自己的代码和改进。 综上所述,oh-my-zsh-git 是在 oh-my-zsh 基础上进行的一些改进和扩展,提供了更多的插件和主题选项,同时注重用户的自定义和扩展能力。用户可以根据自己的需求选择采用哪个版本。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值