A terminal. One window, your shell in it, tabs when you want more than one shell, and a Preferences dialog for everything you can change.
  • C 99.4%
  • Shell 0.4%
  • Makefile 0.1%
Find a file
liquibyte f09f1a32f5
Hanshi 1.9: xtk's text fields keep their right-click menu open
- xtk_entry.c from xtk: the right-click menu of a text field closed as
  soon as it opened. The menu's own keyboard grab sends the field a
  FocusOut, and the field hid its menu on it.
- The version is 1.9.
2026-11-27 16:53:47 -06:00
artwork
doc
hosho
icons
screenshots
shell
src Hanshi 1.9: xtk's text fields keep their right-click menu open 2026-11-27 16:53:47 -06:00
themes
xtk Hanshi 1.9: xtk's text fields keep their right-click menu open 2026-11-27 16:53:47 -06:00
hanshi.desktop
LICENSE
logo.png
Makefile
README.md

Hanshi

A terminal. One window, your shell in it, tabs when you want more than one shell, and a Preferences dialog for everything you can change.

Hanshi (半紙) is the everyday sheet of Japanese paper: the one for daily writing. The order comes written on Hosho (奉書); the daily work is done on Hanshi. It is one of the washi names of the tools around Kami (紙, paper).

Hanshi is built with Hosho: Hosho is the terminal (the screen a program expects, with no display), Hosho's widget draws it with Xtk, and Hanshi is the window around the widget, the settings and the command line.

The wiki is the user manual: every menu item, setting and key, the themes, shell integration for each shell, and each feature of the terminal with the terminal or specification it follows. It is made from the pages in doc/.

What it does

  • Runs your shell, the command of Preferences, or the program named on the command line; the window closes when the program ends, and Hanshi ends with the program's exit status
  • Closing the window while a program still runs in it asks first: Quit or Cancel. A shell that waits at its prompt closes without a question
  • Tabs: Control+Shift+T, or New Tab in the terminal's menu, opens another terminal in a tab; its shell starts in the folder of the shell you were in. The tabs show only while there is more than one terminal. A tab closes when its program ends, and the window with the last tab. A tab can be moved with the mouse. Preferences > Window switches the tabs off
  • A tab's label tells what its shell does (with shell integration): amber for text that waits at the prompt, not sent; and for a tab that does not show, blue while a command runs, then green when it ended with status 0 or red when it failed, until you look at the tab
  • Preferences (Control+Shift+P): a setting shows at once, but for those that a terminal takes when it starts (the command, shell integration on, the rows and columns at the start): those are for the next terminal or window. Apply shows a choice without closing, Cancel puts back what was there, OK keeps it for the next start. Each control has a tooltip that tells what it does; the last page, About Hanshi, shows the versions, the license and the address
  • Everything Hosho's widget does: colors and text styles, wide characters, emoji with skin tones, flags and joined emoji as one character, F13 to F20, ligatures, selection, scrollback with search, links (scheme:// addresses, mailto: and file names), pictures (sixel, iTerm2's and kitty's: picture files, sixel data and compressed data are taken apart in Xtk's jailed worker, a process that can read, write and reach nothing, as what a program prints can come from anyone; without the jail those are not shown. Kitty's plain RGB and RGBA pixels need no taking apart and are shown either way), the right button's menu (Copy, Paste, Find, font size, Clear, Reset), with Hanshi's own items after them: New Tab, Close Tab, Preferences
  • Shell integration for bash, zsh, fish, ksh93, mksh, OpenBSD's ksh, dash and sh (tcsh with one line in ~/.tcshrc): a mark beside each prompt in the color of its command's result, Control+Shift+Up and Down from prompt to prompt, a notification when a long command ends while you work in another window. Each shell tells its folder, tcsh too, so a new tab starts there; your own startup file is still read (~/.kshrc for ksh93 when ENV is not set)
  • A terminal theme file and the background picture are read again when their file changes
  • The window grows and shrinks by whole characters, and keeps its rows and columns when the font changes

Screenshots

The terminal, dark The Hosho Dark terminal theme: a mark beside each prompt, green after a command that succeeded, red after one that failed The terminal, light The same with the Washi terminal theme
Preferences, Appearance Preferences > Appearance: the terminal theme, the font, the cursor Preferences, Programs Preferences > Programs: the shell, keyboard and bell, safety, output
The question before closing Closing the window while a program still runs in it asks first

Build

Hanshi needs the X11 libraries Xtk draws with: x11 xrender xft fontconfig freetype2 xcursor, and Xext and Xpm.

make
./hanshi

make install            # to /usr; PREFIX=/usr/local for another place

make install also puts hanshi.desktop in share/applications and the icon, in each size and as an SVG, in the hicolor icon theme, so the desktop's menu has Hanshi with its icon.

Hosho and Xtk are compiled straight into the program from copies of their own projects (hosho/, xtk/), as Unryu has them: hosho/ from the Hosho project's src/ and its widget from that project's demo/, xtk/ from the Xtk project's src/. Only the Xtk files Hanshi uses are there; the Makefile lists them.

Use

hanshi [-r rows] [-c columns] [-d directory] [-e] [program [argument...]]
Option What it does
-r rows Lines of text, in place of the number in Preferences
-c columns Characters in a line, in place of the number in Preferences
-d directory Where the program starts
-e The last option: what follows is the program and its arguments, also those that start with -, as xterm has it
-v Print the version
-h Print these options

With no program, Hanshi runs the command of Preferences > Programs, or your shell when that is empty.

Keys

Key What it does
Control+Shift+P Preferences
Control+Shift+T A new tab
Control+Shift+W Close the tab
Control+Page Up, Control+Page Down The tab before, the tab after
Control+Shift+C, Control+Shift+V Copy, paste
Shift+Insert, the middle button Paste the selection
Control+Shift+F Search in the scrollback
Control+Shift+Space Select with the keyboard
Control+Shift+O A letter on each link in view, to open one with a key
Control+Shift+Up, Control+Shift+Down From prompt to prompt (shell integration)
Shift+Page Up, Shift+Page Down Scroll
Control+Plus, Control+Minus, Control+0 Font size, for this terminal

The first four are Hanshi's; the others are the widget's own. With the tabs switched off in Preferences, the keys of the tabs go to the program in the terminal. Control+Page Up and Control+Page Down also go to the program while the window has one tab, as there is no other tab to go to.

Tabs

The tabs show while the window has more than one terminal. When the second terminal opens, the window grows by the height of the tabs, and the terminal keeps its rows and columns; when one terminal is left, the window is as it was. The label of a tab is the title its program set ("Terminal" with no title); the window's title is that of the tab that shows.

When the tabs do not fit in the window, two arrows show at the right end of the tabs. The left arrow goes to the tab before the one that shows, and the right arrow to the tab after it; the tabs scroll to keep that tab in view. An arrow is dim at the first or the last tab. The mouse wheel over the tabs scrolls them.

With shell integration (Preferences > Programs), the label of a tab has a color:

The label What it tells When
Amber Text waits at the prompt: it was typed and not sent Always, also for the tab that shows
Blue A command runs Only for a tab that does not show
Green A command ended with status 0 When it ended while the tab did not show, until the tab shows
Red A command ended with another status As green

For a tab that does not show, blue is over green and red, and these are over amber. The colors are the terminal theme's: yellow and bright blue of its palette, and the colors of a prompt's mark (prompt-success, prompt-failure).

To try it: open a second tab, type sleep 15; true and press Return, then go back to the first tab (Control+Page Up). The label of the second tab is blue for 15 seconds, then green. sleep 15; false gives red. Type a word at a prompt and do not press Return: the label is amber. A command gives red when its exit status is not 0, also when it did its work: find has the status 1 when it could not read one folder. echo $? after a command shows its status.

Preferences

Page What is there
Window The window theme (the scrollbar, the menu, the tabs, the dialogs); rows and columns at the start; remember the window's size; tabs on or off
Appearance The terminal's colors: as the window theme, one of Hosho's themes (Hosho Dark, Hosho Light, Sumi, Washi), or a theme file; font family, size, line spacing, ligatures, bold as bright; cursor shape and blink
View Padding, the margin for prompt marks, lines of scrollback, minimum contrast, a background picture and its tint
Programs The command to run, shell integration, the long-command notice; keyboard, bell, answerback; safety (the question before closing, paste confirmation, what a program can do with the clipboard and the window); log file, print command

The background picture (PNG, JPEG, GIF, BMP or XPM) and the log file take a full path or one that starts with ~/. With the Sun, HP, SCO, rxvt or Linux console keyboard, programs get that terminal's TERM when its terminfo entry is installed. "Programs can move and size the window" also covers a program that changes the number of rows and columns.

The settings are kept in ~/.config/hanshi/hanshi.conf (or in $XDG_CONFIG_HOME/hanshi when XDG_CONFIG_HOME is a full path; another value is not used, as the XDG rule says). The file has two sections: [hanshi] for Hanshi's own settings, and [terminal-widget] with the keys that Hosho reads, each with a line that says what it is. You can change the file by hand while Hanshi does not run; Hanshi writes it again when Preferences closes with OK.

The window themes are Xtk's: at each start, Hanshi writes each built-in one that is not there to the themes folder beside its settings (~/.config/hanshi/themes), where you can change them or add your own. A theme that is there is left as it is; delete one to get the built-in one back.

A terminal theme file is one of Hosho's (themes/ has the four built-in ones to copy from). In Preferences name it with a full path, a path that starts with ~/, or a file name in Hanshi's settings folder. A theme gives the colors, the attribute styles and the rules; the settings of Preferences are over those of the theme, but for the font when Preferences names none.

Source

File What it is
src/hanshi.c The window, the tabs, the event loop, the command line, the callbacks of the widget
src/settings.c The settings, their file, and the terminal theme they make
src/settings_dialog.c Preferences
src/ask_dialog.c A question in a dialog: the one before a window with a running program closes
src/modal.c What still runs while a dialog is open: the program in the terminal
src/hanshi_icon.c The program's icon, as the window carries it (made by make artwork)
hosho/ Hosho and its widget (copies)
xtk/ The Xtk files Hanshi uses (copies)
icons/ The icon of the question, from Xtk's icon set (copies)
artwork/ The program's icon: the SVG master and its renders
shell/ Shell integration: a file for each shell (copies of Hosho's)
themes/ Hosho's terminal themes as files, to copy from

Not yet

  • More than one window in one process, and split panes: not planned, and not made unless someone asks for them
  • A tab's settings of its own (a profile for each tab): each tab has the settings of Preferences

License

Artistic License 2.0; see LICENSE.