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

instant coding answers via the command line

howdoi instant coding answers via the command line Sherlock, your neighborhood command-line sloth sleuth. Are you a hack programmer? Do you find yours

Benjamin Gleitzman 9.8k Jan 08, 2023
Ssl-tool - A simple interactive CLI wrapper around openssl to make creation and installation of self-signed certs easy

What's this? A simple interactive CLI wrapper around openssl to make self-signin

Aniket Teredesai 9 May 17, 2022
A 3D engine powered by ASCII art

3D engine powered by ASCII art

Lingdong Huang 48 Nov 16, 2022
A CLI Application to detect plagiarism in Source Code Files.

Plag Description A CLI Application to detect plagiarism in Source Code Files. Features Compare source code files for plagiarism. Extract code features

default=dev 2 Nov 10, 2022
'rl_UK' is an open-source command-line tool in Python for calculating the shortest path between BUS stop sequences in the UK

'rl_UK' is an open-source command-line tool in Python for calculating the shortest path between BUS stop sequences in the UK. As input files, it uses an ATCO-CIF file and 'OS Open Roads' dataset from

Nesh P. 0 Feb 16, 2022
🎈 `st` is a CLI to quickly kick-off your new Streamlit project

🎈 st - a friendly Streamlit CLI st is a CLI that helps you kick-off a new Streamlit project so you can start crafting the app as soon as possible! Ho

Arnaud 18 Dec 19, 2022
Simple command line tool to train and deploy your machine learning models with AWS SageMaker

metamaker Simple command line tool to train and deploy your machine learning models with AWS SageMaker Features metamaker enables you to: Build a dock

Yasuhiro Yamaguchi 5 Jan 09, 2022
term2048 is a terminal-based version of 2048.

term2048 is a terminal-based version of 2048.

Baptiste Fontaine 798 Nov 21, 2022
A simple reverse shell in python

RevShell A simple reverse shell in python Getting started First, start the server python server.py Finally, start the client (victim) python client.py

Lojacopsen 4 Apr 06, 2022
A VIM-inspired filemanager for the console

ranger 1.9.3 ranger is a console file manager with VI key bindings. It provides a minimalistic and nice curses interface with a view on the directory

12.6k Dec 30, 2022
A simple CLI tool for converting logs from Poker Now games to other formats

🂡 Poker Now Log Converter 🂡 A command line utility for converting logs from Poker Now games to other formats. Introduction Poker Now is a free onlin

6 Dec 23, 2022
Access hacksec.in from your command-line

Access hacksec.in from your command-line

hacksec.in 3 Oct 26, 2022
A command line utility to export Google Keep notes to markdown.

Keep-Exporter A command line utility to export Google Keep notes to markdown files with metadata stored as a frontmatter header. Supports exporting: S

Nathan Beals 85 Dec 17, 2022
A simple CLI tool for getting region-specific status of Logz.io components.

About A simple CLI tool for checking the current status of Logz.io components per region. Built With Python 3 The following packeges (see requirements

Yotam Bernaz 1 Dec 11, 2021
Command line tool for google dorks

CLI for google dorks This is the command line tool made with pytohn which allows the users to perform Google dorks easily Installation Install google

subrahmanya s hegade 3 Feb 08, 2022
Convert shellcode into :sparkles: different :sparkles: formats!

Bluffy Convert shellcode into ✨ different ✨ formats! Bluffy is a utility which was used in experiments to bypass Anti-Virus products (statically) by f

AD995 305 Dec 17, 2022
Zecwallet-Python is a simple wrapper around the Zecwallet Command Line LightClient written in Python

A wrapper around Zecwallet Command Line LightClient, written in Python Table of Contents About Installation Usage Examples About Zecw

Priveasy 2 Sep 06, 2022
A Python3 rewrite of my original PwnedConsole project from almost a decade ago

PwnedConsoleX A CLI shell for performing queries against the HaveIBeenPwned? API to gather breach information for user-supplied email addresses. | wri

1 Jul 23, 2022
An awesome Python wrapper for an awesome Docker CLI!

An awesome Python wrapper for an awesome Docker CLI!

Gabriel de Marmiesse 303 Jan 03, 2023
moviepy-cli: Command line interface for MoviePy.

Moviepy-cli is designed to apply several video editing in a single command with Moviepy as an alternative to Video-cli.

Kentaro Wada 23 Jun 29, 2022