目录

theme.sh 自定义 Linux 终端的主题

目录

theme.sh 是一个 Linux 终端的主题项目。内含超过 400 个预编译的主题。

https://github.com/lemnos/theme.sh

特征:
400多个预编译主题
终端不可知论(在任何终端上有OSC4/11支持的作品(例如ST,Kitty,iterm))
保持历史
脚本友好
便携式(包含所有400个主题的单个<130k文件)
黑暗/光线过滤器,因此您可以决定何时要燃烧视网膜。
互动(需要**FZF**)
自我修改(可以摄取小猫咪主题)。
小型,独立且符合POSIX

案例: https://oss-cdn.skiy.net/zzzzy/2023/02/lemnos-theme.sh_.gif


理由:
您可以轻松地在开放式终端内切换主题。
您可以将shell的init文件作为唯一的真相来源。
您可以为所有boxen配置不同的主题(请参阅脚本)。
您可以配置st而无需重新编译:P。


安装: 只要把 theme.sh 放在你的路径上。

Linux

1
 sudo curl -Lo /usr/bin/theme.sh 'https://raw.githubusercontent.com/lemnos/theme.sh/master/bin/theme.sh' && sudo chmod +x /usr/bin/theme.sh
1
sudo curl -Lo /usr/bin/theme.sh 'https://raw.githubusercontent.com/lemnos/theme.sh/master/bin/theme.sh' && sudo chmod +x /usr/bin/theme.sh

MacOS

1
sudo curl -Lo /usr/local/bin/theme.sh 'https://raw.githubusercontent.com/lemnos/theme.sh/master/bin/theme.sh' && sudo chmod +x /usr/local/bin/theme.sh

示例:
有关选项的完整列表,请参见 them.sh -h。

1
2
3
4
5
6
7
8
9
> theme.sh --dark --list

  zenburn
  gruvbox
  solarized-dark
  ...

> theme.sh zenburn
> theme.sh -i #Interactive theme selection (requires fzf)

一旦你找到了你喜欢的主题

1
theme.sh <theme>

配置:
bash 环境要自动加载最近选择的主题,您需将以下内容添加至 ~/.bashrc

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
if command -v theme.sh > /dev/null; then
  [ -e ~/.theme_history ] && theme.sh "$(theme.sh -l|tail -n1)"
  
  # Optional
  
  #Binds C-o to the previously active theme.
  bind -x '"\C-o":"theme.sh $(theme.sh -l|tail -n2|head -n1)"'
  
  alias th='theme.sh -i'
  
  # Interactively load a light theme
  alias thl='theme.sh --light -i'
  
  # Interactively load a dark theme
  alias thd='theme.sh --dark -i'
fi

zsh 环境要自动加载最近选择的主题,您需将以下内容添加至 ~/.zshrc

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
if command -v theme.sh > /dev/null; then
  [ -e ~/.theme_history ] && theme.sh "$(theme.sh -l|tail -n1)"
  
  # Optional
  
  # Bind C-o to the last theme.
  last_theme() {
    theme.sh "$(theme.sh -l|tail -n2|head -n1)"
  }
  
  zle -N last_theme
  bindkey '^O' last_theme
  
  alias th='theme.sh -i'
  
  # Interactively load a light theme
  alias thl='theme.sh --light -i'
  
  # Interactively load a dark theme
  alias thd='theme.sh --dark -i'
fi

vim 相关格式化

~/.vimrc 文件添加

1
2
3
colorscheme default
set notermguicolors
highlight Search ctermfg=0

以上内容使 vim 主题与终端主题配合得很好。