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/.

You might also like...
A command-line based, minimal torrent streaming client made using Python and Webtorrent-cli. Stream your favorite shows straight from the command line.

A command-line based, minimal torrent streaming client made using Python and Webtorrent-cli. Installation pip install -r requirements.txt It use

Textual: a TUI (Text User Interface) framework for Python inspired by modern web development
Textual: a TUI (Text User Interface) framework for Python inspired by modern web development

Textual Textual is a TUI (Text User Interface) framework for Python inspired by

🖥️ A cross-platform modern shell.

Ergonomica WARNING: master on this repository is not the same as a stable release! Currently, this software is purely experimental, as I am cleaning i

Interactive Redis: A Terminal Client for Redis with AutoCompletion and Syntax Highlighting.
Interactive Redis: A Terminal Client for Redis with AutoCompletion and Syntax Highlighting.

Interactive Redis: A Cli for Redis with AutoCompletion and Syntax Highlighting. IRedis is a terminal client for redis with auto-completion and syntax

A Terminal Client for MySQL with AutoCompletion and Syntax Highlighting.
A Terminal Client for MySQL with AutoCompletion and Syntax Highlighting.

mycli A command line client for MySQL that can do auto-completion and syntax highlighting. HomePage: http://mycli.net Documentation: http://mycli.net/

Python commandline tool for remembering linux/terminal commands
Python commandline tool for remembering linux/terminal commands

ehh Remember linux commands Commandline tool for remembering linux/terminal commands. It stores your favorite commands in ~/ehh.json in your homedir a

Open a file in your locally running Visual Studio Code instance from arbitrary terminal connections.

code-connect Open a file in your locally running Visual Studio Code instance from arbitrary terminal connections. Motivation VS Code supports opening

Darkdump - Search The Deep Web Straight From Your Terminal
Darkdump - Search The Deep Web Straight From Your Terminal

Darkdump - Search The Deep Web Straight From Your Terminal About Darkdump Darkdump is a simple script written in Python3.9 in which it allows users to

Random scripts and other bits for interacting with the SpaceX Starlink user terminal hardware
Random scripts and other bits for interacting with the SpaceX Starlink user terminal hardware

starlink-grpc-tools This repository has a handful of tools for interacting with the gRPC service implemented on the Starlink user terminal (AKA "the d

Owner
null
An easy-to-bundle GTK terminal emulator.

EasyTerm An easy-to-bundle GTK terminal emulator. This project is meant to be used as a dependency for other

Bottles 4 May 15, 2022
As easy as /aitch-tee-tee-pie/ 🥧 Modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more. https://twitter.com/httpie

HTTPie: human-friendly CLI HTTP client for the API era HTTPie (pronounced aitch-tee-tee-pie) is a command-line HTTP client. Its goal is to make CLI in

HTTPie 25.4k Dec 30, 2022
Gamestonk Terminal is an awesome stock and crypto market terminal

Gamestonk Terminal is an awesome stock and crypto market terminal. A FOSS alternative to Bloomberg Terminal.

Gamestonk Terminal 18.6k Jan 3, 2023
Baseline is a cross-platform library and command-line utility that creates file-oriented baselines of your systems.

Baselining, on steroids! Baseline is a cross-platform library and command-line utility that creates file-oriented baselines of your systems. The proje

Nelson 4 Dec 9, 2022
Use case: quick JSON processing/restructuring with jq without terminal

alfred-jq Alfred workflow to conveniently process JQ on clipboard based on a jq query Also available at: packal/jq Use case: quick JSON processing/res

T on Meta Mode 5 Sep 30, 2022
A simple command line chat app to communicate via the terminal.

A simple command line chat app to communicate via the terminal. I'm new to networking so sorry if some of my terminology or code is messed up.

PotNoodle 1 Oct 26, 2021
Booky - A command line utility for bookmarking files on your terminal!

Booky A command line utility for bookmarking files for quick access With it you can: Bookmark and delete your (aliases of) files at demand Launch them

Pran 1 Sep 11, 2022
A command-line tool to upload local files and pastebin pastes to your mega account, without signing in anywhere

A command-line tool to upload local files and pastebin pastes to your mega account, without signing in anywhere

ADI 4 Nov 17, 2022
A command-line tool to flash python code to Codey Rocky without having to use the online mblock5 IDE.

What? A command-line tool to flash python code to Codey Rocky without having to use the online mblock5 IDE. Description This is a very low-effort proj

null 1 Dec 29, 2021
Easily turn single threaded command line applications into a fast, multi-threaded application with CIDR and glob support.

Easily turn single threaded command line applications into a fast, multi-threaded application with CIDR and glob support.

Michael Skelton 1k Jan 7, 2023