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 key binds

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.0.tar.gz (11.3 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.0-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: textual_shell-0.9.0.tar.gz
  • Upload date:
  • Size: 11.3 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.0.tar.gz
Algorithm Hash digest
SHA256 a54ff630348b75acd56d01d1c16fd1bc2062e02a0529f4bc060bb0ce4cf31528
MD5 e06aa910ec31aa6c2f072013f7c68c2e
BLAKE2b-256 371697b0a3ca02fdcb041ef25525b6a0e6f299b9e14bcebf84ceaff86ac5aa3b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: textual_shell-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 12.0 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7783a8b867395f87cd6f36a57c84e7ee1a6c38752ec8eef7c62ce0dbbea8cf1c
MD5 9fb9690a19d27a1bcd26c670306d4fbb
BLAKE2b-256 6801299fd09b9041786caa5a1bf90718a4bda5c1190b847a78d79eb5aa444d15

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