Skip to main content

A shell widget for textual.

Project description

Textual-Shell

Welcome to the Textual-Shell documentation! This is an addon for the Textual framework.

What is Textual-Shell?

It is a collection of widgets that can be used to build a custom shell application. It draws inspiration from the cmd2 and prompt-toolkit libraries.

Quick Start

Install it with:

pip install textual-shell
import os

from textual.app import ComposeResult
from textual.containers import Grid
from textual.geometry import Offset
from textual.widgets import Header, Footer

from textual_shell.app import ShellApp
from textual_shell.command import Help, Set
from textual_shell.widgets import CommandList, Shell, SettingsDisplay

class BasicShell(ShellApp):
    
    CSS_PATH = 'style.css'
    theme = 'tokyo-night'
        
    cmd_list = [Help(), Set()]
    command_names = [cmd.name for cmd in cmd_list]
    CONFIG_PATH = os.path.join(os.environ.get('HOME', os.getcwd()), '.config.yaml')
    HISTORY_LOG = os.path.join(os.environ.get('HOME', os.getcwd()), '.shell_history.log')
    
    def compose(self) -> ComposeResult:
        yield Header()
        yield Footer()
        yield Grid(
            CommandList(self.command_names),
            Shell(
                self.cmd_list,
                prompt='prompt <$ ',
                suggestion_offset=Offset(10, 3)
            ),
            SettingsDisplay(self.CONFIG_PATH),
            id='app-grid'
        )
        
        
if __name__ == '__main__':
    BasicShell().run()

TODO:

  • Command line validation
  • write documentation on Commands
  • write documentation on shell key binds
  • redo suggestions location logic.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

textual_shell-0.9.2.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

textual_shell-0.9.2-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file textual_shell-0.9.2.tar.gz.

File metadata

  • Download URL: textual_shell-0.9.2.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.0rc1

File hashes

Hashes for textual_shell-0.9.2.tar.gz
Algorithm Hash digest
SHA256 da71f3210fd3a960379bddcf7a7330a783661dfe01d27d94c6bd49d4b28f1a4b
MD5 d1d64c74ac006b188f044cde27db025f
BLAKE2b-256 3af526c7efb3cecbb15ebae38107e5b3cb3ea80bb744bdefcc7c21016800b84e

See more details on using hashes here.

File details

Details for the file textual_shell-0.9.2-py3-none-any.whl.

File metadata

  • Download URL: textual_shell-0.9.2-py3-none-any.whl
  • Upload date:
  • Size: 14.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.0rc1

File hashes

Hashes for textual_shell-0.9.2-py3-none-any.whl
Algorithm Hash digest
SHA256 07aee90f6e96d8aef68aa9f751ea08e0cd0fbed55e8e8e7441fa31da5f31eb31
MD5 00807a554494710c6b894e2a615a4987
BLAKE2b-256 48d42c520ae0aa8b20150c9d3c43ababc29e49eadda9cf036208233694ec0b20

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page