st
st 是一個簡單的由 suckless 製作的用於 Xorg 上的終端實現。它被用作 xterm 或 urxvt 的輕量替代。它當前支持 256 顏色,真顏色,大多數 VT10X 轉義序列,UTF-8,X11 複製/粘貼,抗鋸齒字體,備用字體,調整大小,快捷鍵和線描。
安裝[編輯 | 編輯原始碼]
安裝 stAUR 軟件包 或 開發版本的 st-gitAUR 軟件包。
配置[編輯 | 編輯原始碼]
st 是通過它在編譯時被複製的 config.h
文件來配置的。默認配置保存在原始碼中的 config.def.h
。考慮製作你自己的 config.h
和 PKGBUILD。
Shell[編輯 | 編輯原始碼]
要想修改 st 的默認 shell ,編輯這一行:
static char *shell = "/bin/sh";
或將你想要的 shell 作為最後一個參數啟動 st :
$ st options fish
終端[編輯 | 編輯原始碼]
要想修改終端的類型, 編輯這一行:
static char *termname = "st-256color";
st 會將 TERM
變量的值設置為 termname
。
字體[編輯 | 編輯原始碼]
根據你的喜好編輯下面這一行:
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 網站 有許多補丁。要想使用補丁,下載 diff 並且使用 patch -i patch.diff
命令來安裝補丁。這會修改默認的配置文件 config.def.h
;如果你正在製作你自己的 config.h
,將你的配置從 config.h
複製到一份 config.def.h
的副本中並且將它重命名為 config.h
,然後執行 make clean install
命令。
Desktop 條目[編輯 | 編輯原始碼]
要想用在桌面環境優美的字體(例如 adobe-source-code-pro-fonts包)簡化 st的啟動,你可以創建一個 Desktop 條目:
~/.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出現。
故障排除[編輯 | 編輯原始碼]
鍵盤[編輯 | 編輯原始碼]
將下列內容添加到 ~/.inputrc
或 /etc/inputrc
如果 {{ic}Delete}} 不能在某些應用裡正常工作。
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
中打出來。在 INSERT 模式中,按下 Ctrl+v
然後按 Esc
。你還會保持在 INSERT 模式;再次按下 Esc
來回到 NORMAL 模式。
colorscheme
, t_Co
和 termguicolors
之前設置 t_8f
和 t_8b
。要想獲得更多信息,請見 vim
中的 :help
: xterm-true-color
, t_8f
, t_8b
。