st
st is a simple terminal implementation for Xorg by suckless. It is intended to serve as a lightweight replacement for xterm or urxvt. It currently supports 256 colors, true colors, most VT10X escape sequences, UTF-8, X11 copy/paste, anti-aliased fonts, fallback fonts, resizing, shortcuts, and line drawing.
Installation
Install the stAUR package or st-gitAUR for the development version.
- On Wayland, st uses Xwayland; at this current time there is no active Wayland port of st available, the Xwayland memory-footprint is unavoidable.
Configuration
st is configured through its config.h
file which is copied over at compile time. Defaults are stored in config.def.h
which is included with the source. Consider maintaining your own config.h
and PKGBUILD.
Shell
To change the default shell for st, edit this line:
static char *shell = "/bin/sh";
Or start st with the desired shell as last argument:
$ st options fish
Term
To change the terminal type, edit this line:
static char *termname = "st-256color";
st will set the TERM
variable with the value of termname
.
Font
Edit the following line as you prefer:
static char *font = "Liberation Mono:pixelsize=12:antialias=false:autohint=false";
You can also pass the value of the font in the command line:
$ st -f "Liberation Mono:size=12" $ st -f 'Liberation Mono-12'
Font names can be found with fc-list
.
Cursor
By default, the mouse pointer is XC_xterm;
which often can be hard to find. To change it to your cursor theme's normal one, edit the following:
static unsigned int mouseshape = XC_left_ptr;
Colors
Edit the following lines to set foreground, background, and cursor colors:
unsigned int defaultfg = 7; unsigned int defaultbg = 0; static unsigned int defaultcs = 256;
The values refer to the *colorname[]
array in the configuration file. You can use the default colors or add yours in #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;
Tools exist to facilitate the creation of color palettes. For example, terminal.sexy has a set of pre-made ones and exports directly to st's format (see comment on issue 22).
There is a patch for the Solarized color scheme. See https://st.suckless.org/patches/solarized/ to install it.
Patches
There are many patches available from the suckless website. To apply a patch, download the diff and apply it with patch -i patch.diff
. This alters the default configuration file config.def.h
; if you are maintaining your own config.h
, copy your configs from config.h
into a copy of config.def.h
and rename it config.h
, then make clean install
.
Desktop entry
To simplify launching st with a decent font (e.g. adobe-source-code-pro-fonts) in a desktop environment, you can also create a desktop entry:
~/.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;
The menu entry will appear as Simple Terminal in the System Tools application list.
Troubleshooting
Keyboard
Add the following to ~/.inputrc
or /etc/inputrc
if Delete
is not working properly in some applications:
set enable-keypad on
If the above does not work with some applications such as IPython using bash, instead, turn off enable-keypad
and add the following to your ~/.bashrc
, as mentioned in the st FAQ:
printf '\033[?1h\033=' >/dev/tty
Vim
The background colour of text in vim will not fill in anything that is not a character
Try setting the value of termname
in your config.h
to st-256color
and recompiling. And do not set the TERM
var in your shell, at least not to st-256color
as this seems to cause the issue.
Another solution, perhaps a better one, is to have the following lines in your .vimrc
file:
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
256color and truecolor support not working in tmux or otherwise
First, make sure you are not setting and exporting the value of TERM
in your ~/.bashrc
as mentioned in this thread
TERM
. Do it right by setting the default-terminal
setting in your tmux.conf
Second, make sure the version of vim
you are using is >=7.4.1799
, which is when termguicolors
was added.
Finally, add the following to ~/.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
^[
is a literal escape (Esc
) character that prefixes each of the values for t_8f
and t_8b
. It is a single character, which can be reproduced in vim
. In INSERT mode, press Ctrl+v
then Esc
. You will still be in INSERT mode; press Esc
again to return to NORMAL mode.
t_8f
and t_8b
prior to setting colorscheme
, t_Co
and termguicolors
.For more information, see the :help
in vim
for: xterm-true-color
, t_8f
, t_8b
Arabic shaping support
As explained in Vim#Bidirectional support, for full Arabic character support, you need a fallback font covering the Unicode entries for Arabic Forms-B. To do that, add font2 patch and edit your config as follows:
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" };
Then launch st
with st -f 'Vazir Code:pixelsize=15'
. This set up covers most Arabic shaping cases: no shaping, italicized no shaping, Forms-B, italicized Forms-B.