st
st 是一个由 suckless 开发的用于 Xorg 的简单终端实现。它旨在作为 xterm 或 urxvt 的轻量级替代品。它目前支持 256 色、真彩色、大多数 VT10X 转义序列、UTF-8、X11 复制/粘贴、抗锯齿字体、后备字体、调整大小、快捷方式和线条绘制。
安装
- 在 Wayland 上,st 使用 Xwayland;目前还没有可用的 st 的 Wayland 端口,Xwayland 的内存占用是不可避免的。
配置
st 通过其 config.h 文件进行配置,该文件在编译时被复制。默认值存储在源代码附带的 config.def.h 中。考虑维护您自己的 config.h 和 PKGBUILD。
Shell
要更改 st 的默认 shell,请编辑此行
static char *shell = "/bin/sh";
或使用所需的 shell 作为最后一个参数启动 st
$ st options fish
Term
要更改终端类型,请编辑此行
static char *termname = "st-256color";
st 将使用 termname 的值设置 TERM 变量。
字体
根据您的喜好编辑以下行
static char *font = "Liberation Mono:pixelsize=12:antialias=false:autohint=false";
您也可以在命令行中传递字体的值
$ st -f "Liberation Mono:size=12" $ st -f 'Liberation Mono-12'
字体名称可以使用 fc-list 找到。
光标
默认情况下,鼠标指针是 XC_xterm;,这通常很难找到。要将其更改为光标主题的普通光标,请编辑以下内容
static unsigned int mouseshape = XC_left_ptr;
颜色
编辑以下行以设置前景色、背景色和光标颜色
unsigned int defaultfg = 7; unsigned int defaultbg = 0; static unsigned int defaultcs = 256;
这些值是指配置文件中的 *colorname[] 数组。您可以使用默认颜色或在 #rrggbb 中添加您自己的颜色
static const char *colorname[] = {
/* 8 normal colors */
"black",
"red3",
"green3",
"yellow3",
"blue2",
"magenta3",
"cyan3",
"gray90",
/* 8 bright colors */
"gray50",
"red",
"green",
"yellow",
"#5c5cff",
"magenta",
"cyan",
"white",
[255] = 0,
/* more colors can be added after 255 to use with DefaultXX */
"#cccccc",
"#eeeeee",
"#111111",
};
/*
* Default colors (colorname index)
* foreground, background, cursor
*/
unsigned int defaultfg = 257;
unsigned int defaultbg = 258;
static unsigned int defaultcs = 256;
存在一些工具来方便创建调色板。例如,terminal.sexy 具有一组预制调色板,并直接导出为 st 的格式(参见 issue 22 上的评论)。
有一个用于 Solarized 配色方案的补丁。请参阅 https://st.suckless.org/patches/solarized/ 以安装它。
补丁
suckless 网站 suckless website 提供了许多补丁。要应用补丁,请下载 diff 并使用 patch -i patch.diff 应用它。这将更改默认配置文件 config.def.h;如果您正在维护自己的 config.h,请将您的配置从 config.h 复制到 config.def.h 的副本中并将其重命名为 config.h,然后 make clean install。
桌面条目
为了简化在 桌面环境 中使用合适的字体(例如 adobe-source-code-pro-fonts)启动 st,您还可以创建一个 桌面条目
~/.local/share/applications/st.desktop
[Desktop Entry] Name=Simple Terminal GenericName=Terminal Comment=Suckless terminal emulator for X Exec=st -t "Simple Terminal" -f "Source Code Pro:style=Semibold:size=12" Terminal=false Type=Application Encoding=UTF-8 Icon=utilities-terminal Categories=System;TerminalEmulator; Keywords=shell;prompt;command;commandline;cmd;
菜单条目将在系统工具应用程序列表中显示为Simple Terminal。
故障排除
键盘
如果 Delete 在某些应用程序中无法正常工作,请将以下内容添加到 ~/.inputrc 或 /etc/inputrc
set enable-keypad on
如果上述方法不适用于某些应用程序(例如使用 bash 的 IPython),请关闭 enable-keypad 并将以下内容添加到您的 ~/.bashrc 中,如 st FAQ 中所述
printf '\033[?1h\033=' >/dev/tty
Vim
vim 中文本的背景颜色不会填充非字符区域
尝试将 config.h 中的 termname 值设置为 st-256color 并重新编译。并且不要在您的 shell 中设置 TERM 变量,至少不要设置为 st-256color,因为这似乎会导致问题。
另一种解决方案,也许是更好的解决方案,是在您的 .vimrc 文件中添加以下行
if &term =~ '256color'
" disable Background Color Erase (BCE) so that color schemes
" render properly when inside 256-color tmux and GNU screen.
" see also https://sunaku.github.io/vim-256color-bce.html
set t_ut=
endif
256 色和真彩色支持在 tmux 或其他情况下不起作用
首先,请确保您没有像这个 帖子 中提到的那样在您的 ~/.bashrc 中设置和导出 TERM 的值
TERM。通过在您的 tmux.conf 中设置 default-terminal 设置来正确执行此操作其次,确保您正在使用的 vim 版本 >=7.4.1799,这是添加 termguicolors 的版本。
最后,将以下内容添加到 ~/.vimrc
set t_8f=^[[38;2;%lu;%lu;%lum " set foreground color set t_8b=^[[48;2;%lu;%lu;%lum " set background color colorscheme Tomorrow-Night-Eighties set t_Co=256 " Enable 256 colors set termguicolors " Enable GUI colors for the terminal to get truecolor
^[ 是一个文字转义 (Esc) 字符,它作为 t_8f 和 t_8b 的每个值的前缀。它是一个字符,可以在 vim 中重现。在插入模式下,按 Ctrl+v 然后 Esc。您仍将处于插入模式;再次按 Esc 返回到普通模式。colorscheme、t_Co 和 termguicolors 之前设置 t_8f 和 t_8b 的值。有关更多信息,请参阅 vim 中关于:xterm-true-color、t_8f、t_8b 的 :help
阿拉伯字符塑形支持
如 Vim#双向支持 中所述,要获得完整的阿拉伯字符支持,您需要一个后备字体,覆盖阿拉伯文 Forms-B 的 Unicode 条目。为此,添加 font2 补丁并按如下方式编辑您的配置
static char *font = "Cascadia Code:size=12:pixelsize=13:antialias=true:autohint=true";
static char *font2[] = { "DejaVu Sans Mono:size=12:pixelsize=13:antialias=true:autohint=true" };
然后使用 st -f 'Vazir Code:pixelsize=15' 启动 st。此设置涵盖了大多数阿拉伯字符塑形情况:无塑形、斜体无塑形、Forms-B、斜体 Forms-B。