Modern line-oriented terminal emulator without support for TUIs.

Overview

saneterm

Modern line-oriented terminal emulator without support for TUIs.

saneterm demo

Motivation

Mainstream terminal emulators (urxvt, xterm, alacritty, …) support a standard known as ANSI escape sequences. This standard defines several byte sequences to provide special control functions for terminals emulators. This includes control of the cursor, support for different colors, et cetera. They are often used to implement TUIs, e.g. using the ncurses library.

Many of these escape sequences operate on rows and columns and therefore require terminal emulators to be built around a character grid were individual cells can be modified. Historically, this was very useful to implement UIs on physical terminals like the VT100. Nowadays this approach feels dated and causes a variety of problems. For instance, the concept of grapheme cluster as used in Unicode is largely incompatible with fixed-size columns. For this reason, terminal emulator supporting the aforementioned escape sequences can never fully support Unicode [1].

On the other hand, a terminal emulator not supporting ANSI escape sequences can never support existing TUIs. However, the idea behind saneterm is that terminals shouldn't be used to implement TUIs anyhow, instead they should focus on line-based CLIs. By doing so, a variety of features normally implemented in CLI programs themselves (like readline-keybindings) can be implemented directly in the terminal emulator.

Status

Silly, buggy, and incomplete prototype implementation.

Features

By focusing on line-based input in the terminal emulator a variety of things can be simplified and improved. saneterm is presently just a prototype and provides basic implementations of the following features:

  • Full Unicode support
  • Support for readline-like line editing keybindings
  • Editing history support directly in the terminal emulator
  • File name completions
  • Pager-like text handling (scrolling, searching, …)

Installation

This software has the following dependencies:

If these are installed run the following command to install saneterm:

$ python3 setup.py install --optimize=1

For development setups just run python3 -msaneterm.

Usage

Since many modern day shells use ANSI escape sequences heavily for providing editing features, your favorite shell might not directly work with saneterm. Simple shells like dash are known to work well though. You might also want to consider using a clean environment, to do so run the following command to start saneterm:

$ saneterm -- env -i dash

Configuration

The terminal appearance can be configured using Gtk's CSS feature. The saneterm window widget can be selected using the CSS selector #saneterm.

For example, to change the color scheme and employed font. Add the following to your gtk.css configuration file located at $XDG_CONFIG_HOME/gtk-3.0/gtk.css:

#saneterm textview {
	font-family: Terminus;
	font-size: 16px;
}

#saneterm textview text {
	background-color: #181818;
	color: #d8d8d8;

	/* change cursor color too */
	caret-color: #d8d8d8;
}

Keybindings can be configured using the same mechanism, see keys.py for the default keybindings.

FAQ

Q: How do I edit text on remote machines over SSH if my terminal emulator doesn't support visual editors?

A: This is an interesting problem since a lot of software relies on TUIs to be used over PTYs and SSH on remote machines. This is mostly also an inherit flaw of Unix as it hasn't been designed with networking and GUIs in mind. Plan 9 solves this problem through 9P file servers, but unfortunately it has not been widely adopted and we are stuck with Unix. In the Unix world potential solutions include CLI-based editors (e.g. ed) or network protocols tunneled over SSH connections (e.g. Emacs Tramp Mode).

Q: How do I use pagers (e.g. less(1)) without support for TUIs?

A: With saneterm pagers are not needed as paging functionality is implemented in the terminal emulator itself. For this reason, saneterm offers a scrollback buffer in which autoscrolling can be configured using the Gtk context menu. Furthermore, word wrapping can also be disabled using the same mechanism. A search feature is also implemented and can be activated using ctrl+f.

Q: Why is this written in Python and not X?

A: This software is presently just a silly prototype, Python is good for prototyping. Furthermore, Python has decent, somewhat well-documented bindings for Gtk.

Related Work

This work is heavily inspired by the Plan 9 terminal emulator, usage of which is further described in the rio(1) man page. This terminal emulator was also ported to Unix as part of plan9port.

There are also a few projects which seem to share the problem statement outlined in the Motivation but propose different solution. Most of which include continued support for TUIs and therefore don't benefit from other line-based editing features. Non-complete list:

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Tncli - TON smart contract command line interface

Tncli TON smart contract command line interface State Not working, in active dev

Disintar IO 100 Dec 18, 2022
Output Analyzer for you terminal commands

Output analyzer (OZER) You can specify a few words inside config.yaml file and specify the color you want to be used. installing: Install command usin

Ehsan Shirzadi 1 Oct 21, 2021
Python command line tool and python engine to label table fields and fields in data files.

Python command line tool and python engine to label table fields and fields in data files. It could help to find meaningful data in your tables and data files or to find Personal identifable informat

APICrafter 22 Dec 05, 2022
An interactive cheatsheet tool for the command-line

navi An interactive cheatsheet tool for the command-line. navi allows you to browse through cheatsheets (that you may write yourself or download from

Denis Isidoro 12.2k Dec 31, 2022
Bear-Shell is a shell based in the terminal or command prompt.

Bear-Shell is a shell based in the terminal or command prompt. You can navigate files, run python files, create files via the BearUtils text editor, and a lot more coming up!

MichaelBear 6 Dec 25, 2021
dbt-subdocs is a python CLI you can used to generate a dbt-docs for a subset of your dbt project

dbt-subdocs dbt-subdocs is a python CLI you can used to generate a dbt-docs for a subset of your dbt project 🤔 Description This project is useful if

Jambe 6 Jan 03, 2023
Chat with Rem in Terminal!

Chat with Rem in Terminal!

bariscodefx 1 Dec 19, 2021
An open source terminal project made in python

Calamity-Terminal An open source terminal project made in python. Calamity Terminal is a free and open source lightweight terminal. Its made 100% off

1 Mar 08, 2022
A simple CLI based any Download Tool, that find files and let you stream or download thorugh WebTorrent CLI or Aria or any command tool

Privateer A simple CLI based any Download Tool, that find files and let you stream or download thorugh WebTorrent CLI or Aria or any command tool How

Shreyash Chavan 2 Apr 04, 2022
Enriches Click with option groups, constraints, command aliases, help sections for subcommands, themes for --help and other stuff.

Enriches Click with option groups, constraints, command aliases, help sections for subcommands, themes for --help and other stuff.

Gianluca Gippetto 62 Dec 22, 2022
Terminal-based keyboard testing

kbdtest kbdtest is a simple Python program that tests keyboard input using an interactive, terminal-based, visual keyboard display. It was originally

Ruunyox 12 Jul 19, 2022
A ZSH plugin that enables you to use OpenAI's powerful Codex AI in the command line.

A ZSH plugin that enables you to use OpenAI's powerful Codex AI in the command line.

Tom Dörr 976 Jan 03, 2023
Command-line program for organizing and managing ebook collections

Command-line program for organizing and managing ebook collections. It is a Python port from the original shell scripts ebook-tools

Raul 14 Nov 12, 2022
Postgres CLI with autocompletion and syntax highlighting

A REPL for Postgres This is a postgres client that does auto-completion and syntax highlighting. Home Page: http://pgcli.com MySQL Equivalent: http://

dbcli 10.8k Jan 02, 2023
Sink is a CLI tool that allows users to synchronize their local folders to their Google Drives. It is similar to the Git CLI and allows fast and reliable syncs with the drive.

Sink is a CLI synchronisation tool that enables a user to synchronise local system files and folders with their Google Drives. It follows a git C

Yash Thakre 16 May 29, 2022
Autosub - Command-line utility for auto-generating subtitles for any video file

Auto-generated subtitles for any video Autosub is a utility for automatic speech recognition and subtitle generation. It takes a video or an a

Anastasis Germanidis 3.9k Jan 05, 2023
A command line tool to hide and reveal information inside images (works for both PNGs and JPGs)

ImgReRite A command line tool to hide and reveal information inside images (work

Jigyasu 10 Jul 27, 2022
A simple CLI productivity tool to quickly display the syntax of a desired piece of code

Iforgor Iforgor is a customisable and easy to use command line tool to manage code samples. It's a good way to quickly get your hand on syntax you don

Solaris 21 Jan 03, 2023
command line tool for frequent nmigen tasks (generate sources, show design)

nmigen-tool command line tool for frequent nmigen tasks (generate sources, show design) Usage: generate verilog: nmigen generate verilog nmigen_librar

Hans Baier 8 Nov 27, 2022
Command line, configuration and persistence utilities

Zensols Utilities Command line, configuration and persistence utilities generally used for any more than basic application. This general purpose libra

Paul Landes 2 Nov 17, 2022