Difference between revisions of "St"

From ArchWiki
Jump to: navigation, search
(replaced external links (interactive))
(Tag: wiki-scripts)
 
(42 intermediate revisions by 14 users not shown)
Line 1: Line 1:
 
{{Lowercase title}}
 
{{Lowercase title}}
 
[[Category:Terminal emulators]]
 
[[Category:Terminal emulators]]
[http://st.suckless.org/ st] is a simple terminal implementation for X by [http://suckless.org suckless]. It is intended to serve as a lightweight replacement [[xterm]] and [[rxvt-unicode|urxvt]]. It currently supports 256 colors, most VT10X escape sequences, UTF8, X11 copy/paste, antialiased fonts (using fontconfig), fallback fonts, resize, shortcuts via config.h, and line drawing.  
+
[[ja:St]]
 +
[http://st.suckless.org/ st] is a simple terminal implementation for [[X]] by [http://suckless.org 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 (using fontconfig), fallback fonts, resizing, shortcuts via config.h, and line drawing.
  
==Installation==
+
== Installation ==
Download the {{AUR|st}} or {{AUR|st-git}} package from the [[AUR]]. Then, as a non-root user, run:
+
  
$ makepkg -i
+
[[Install]] the {{Pkg|st}} or {{AUR|st-git}} package.
  
while in the directory of the saved [[PKGBUILD]]. All the files will be retrieved, and the package will be built and installed.
+
== Configuration ==
 +
''st'' is configured through its {{ic|config.h}} file, which is copied over from {{ic|config.h}} at compile time. A default {{ic|config.def.h}} is included with the source.  
  
==Configuration==
+
Consider maintaining your own [[PKGBUILD]] with your {{ic|config.h}}.
st is configured through its {{ic|config.h}} file. A sample {{ic|config.def.h}} file is included with the source.  
+
  
Consider maintaining your own [[PKGBUILD]] with sources and md5sums for your own configuration file.
+
=== Shell ===
  
==Weird glitches/Visual bugs==
+
To change the default shell for ''st'', edit this line:
Vim: Background colour of the text in Vim will not fill in anything that wasn't a character.
+
  
Solution: set TERM variable to screen-256color in your config.h file.
+
  static char shell[] = "/bin/sh";
 +
 
 +
=== Term ===
 +
 
 +
To change the terminal type, edit this line:
 +
 
 +
  static char termname[] = "st-256color";
 +
 
 +
''st'' will set the {{ic|TERM}} variable with the value of {{ic|termname}}.
 +
 
 +
{{note|If you experience trouble with ''st'', you can try to set {{ic|termname}} to {{ic|xterm}} or {{ic|xterm-256color}} }}
 +
 
 +
=== 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"
 +
 
 +
=== Colors ===
 +
 
 +
Edit the following line to set ''foreground'', ''background'' and ''cursor'' colors:
 +
 
 +
  static unsigned int defaultfg = 7;
 +
  static unsigned int defaultbg = 0;
 +
  static unsigned int defaultcs = 256;
 +
 
 +
The values refer to the {{ic|*colorname[]}} array in the same file, you can use default color or add yours in {{ic|#rrggbb}}, for example:
 +
 
 +
  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
 +
  */
 +
  static unsigned int defaultfg = 257;
 +
  static unsigned int defaultbg = 258;
 +
  static unsigned int defaultcs = 256;
 +
 
 +
=== Desktop entry ===
 +
To simplify launching ''st'' with a decent font e.g. {{Pkg|adobe-source-code-pro-fonts}}, you can also create a [[desktop entry]]:
 +
 
 +
{{hc|~/.local/share/applications/simple-terminal.desktop|2=
 +
[Desktop Entry]
 +
Name=Simple Terminal
 +
GenericName=Terminal
 +
Comment=standard terminal emulator for the X window system
 +
Exec=st -t "Suckless Terminal" -f "Source Code Pro:style=Semibold:size=16" -g "80x24"
 +
Terminal=false
 +
Type=Application
 +
Encoding=UTF-8
 +
Icon=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 ===
 +
==== DEL-Key not working properly in some Application ====
 +
add following to ''~/.inputrc'' or ''/etc/inputrc'':
 +
  set enable-keypad on
 +
 
 +
==== Backspace not working properly ====
 +
 
 +
{{Note | According to the [http://git.suckless.org/st/tree/FAQ FAQ], this behavior has been changed in the upstream, and the issue can be fixed upgrading to the latest version. }}
 +
 
 +
While virtual terminal and most popular terminal emulator for X bind {{ic|backscape}} key to {{ic|^?}} escape sequence, older version of {{ic|st}} bind it to {{ic|^H}}, as explained in older version of the FAQ.
 +
 
 +
If hitting the {{ic|backspace}} key while typing on standard input of some programs (like {{ic|read}}) prints {{ic|^H}} instead of erasing, you can fix that with:
 +
 
 +
stty erase '^H'
 +
 
 +
This will make the terminal interprets {{ic|^H}} as an erase command.
 +
 
 +
If you want to put the above command in a shell profile, you should consider checking the {{ic|$TERM}} before launch it.
 +
 
 +
As of version {{ic|0-6}}, {{ic|st}} interpret backspace as {{ic|^?}} by default. An exception is when {{ic|Alt+BackSpace}} pressed, {{ic|st}} sends {{ic|^[^H}} instead of {{ic|^[^?}} ({{Bug|50000}}). This inconsistent behavior leads to bad experience, especially on Emacs when pressing {{ic|Alt+BackSpace}} no longer delete a word backwards. To fix this, adding a line on {{ic|config.h}} is needed.
 +
<pre><nowiki>
 +
      { XK_BackSpace,    Mod1Mask,      "\033\177",      0,    0,    0},
 +
</nowiki></pre>
 +
Rebuild the package to apply the change.
 +
 
 +
=== Vim ===
 +
==== The background colour of text in ''vim'' will not fill in anything that is not a character ====
 +
Try setting the value of {{ic|termname}} in your {{ic|config.h}} to {{ic|st-256color}} and recompiling. And do not set the {{ic|TERM}} var in your shell, at least not to {{ic|st-256color}} as this seems to cause the issue.
 +
 
 +
Another solution, perhaps a better one, is to have the following lines in your {{ic|.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 http://sunaku.github.io/vim-256color-bce.html
 +
    set t_ut=
 +
endif
 +
 
 +
== See also ==
 +
*[http://st.suckless.org/ Homepage]
 +
*[http://git.suckless.org/st/plain/FAQ Frequently asked questions]
 +
*[http://git.suckless.org/st/ Official git repository]

Latest revision as of 21:36, 16 July 2016

st is a simple terminal implementation for X 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 (using fontconfig), fallback fonts, resizing, shortcuts via config.h, and line drawing.

Installation

Install the st or st-gitAUR package.

Configuration

st is configured through its config.h file, which is copied over from config.h at compile time. A default config.def.h is included with the source.

Consider maintaining your own PKGBUILD with your config.h.

Shell

To change the default shell for st, edit this line:

 static char shell[] = "/bin/sh";

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.

Note: If you experience trouble with st, you can try to set termname to xterm or xterm-256color

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"

Colors

Edit the following line to set foreground, background and cursor colors:

 static unsigned int defaultfg = 7;
 static unsigned int defaultbg = 0;
 static unsigned int defaultcs = 256;

The values refer to the *colorname[] array in the same file, you can use default color or add yours in #rrggbb, for example:

 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
  */
 static unsigned int defaultfg = 257;
 static unsigned int defaultbg = 258;
 static unsigned int defaultcs = 256;

Desktop entry

To simplify launching st with a decent font e.g. adobe-source-code-pro-fonts, you can also create a desktop entry:

~/.local/share/applications/simple-terminal.desktop
[Desktop Entry]
Name=Simple Terminal
GenericName=Terminal
Comment=standard terminal emulator for the X window system
Exec=st -t "Suckless Terminal" -f "Source Code Pro:style=Semibold:size=16" -g "80x24"
Terminal=false
Type=Application
Encoding=UTF-8
Icon=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

DEL-Key not working properly in some Application

add following to ~/.inputrc or /etc/inputrc:

 set enable-keypad on

Backspace not working properly

Note: According to the FAQ, this behavior has been changed in the upstream, and the issue can be fixed upgrading to the latest version.

While virtual terminal and most popular terminal emulator for X bind backscape key to ^? escape sequence, older version of st bind it to ^H, as explained in older version of the FAQ.

If hitting the backspace key while typing on standard input of some programs (like read) prints ^H instead of erasing, you can fix that with:

stty erase '^H'

This will make the terminal interprets ^H as an erase command.

If you want to put the above command in a shell profile, you should consider checking the $TERM before launch it.

As of version 0-6, st interpret backspace as ^? by default. An exception is when Alt+BackSpace pressed, st sends ^[^H instead of ^[^? (FS#50000). This inconsistent behavior leads to bad experience, especially on Emacs when pressing Alt+BackSpace no longer delete a word backwards. To fix this, adding a line on config.h is needed.

       { XK_BackSpace,     Mod1Mask,       "\033\177",      0,    0,    0},

Rebuild the package to apply the change.

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 http://sunaku.github.io/vim-256color-bce.html
    set t_ut=
endif

See also