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.widgets import Header, Footer

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

class BasicShell(ShellApp):
    
    CSS = """
        Grid {
            grid-size: 3;
            grid-rows: 1fr;
            grid-columns: 20 2fr 1fr;
            width: 1fr;
        }
    """
    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 <$ '
            ),
            SettingsDisplay(self.CONFIG_PATH),
            Container(),
            Container(),
            CommandLog()
        )
        
        
if __name__ == '__main__':
    BasicShell().run()

TODO:

  • Command line validation
  • write documentation on Commands
  • write documentation on shell 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.5.tar.gz (13.9 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.5-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: textual_shell-0.9.5.tar.gz
  • Upload date:
  • Size: 13.9 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.5.tar.gz
Algorithm Hash digest
SHA256 b22b6d6a24f3d28065cae5a95b133580ddc88d762c65b33b090cbee494f7eba8
MD5 aefd909d93407f811bcaecbf6250a450
BLAKE2b-256 eae0ceb011c6d576a6ecb36d1f917482e4bdb1a28759e83db62a93f8c52166c0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: textual_shell-0.9.5-py3-none-any.whl
  • Upload date:
  • Size: 17.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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 780e38cd01201da14178279e74ebb890c5304bebdf14e0ceafd3ad45d4eeebe7
MD5 5e08513b7f34865c8009d93c769ce156
BLAKE2b-256 dd4504657326296844a2708f61d93268eced5b2302f7e73dd2cc088e30c97409

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