tweety

command module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2025 License: MIT Imports: 21 Imported by: 0

README

Tweety - An Integrated Terminal for your Browser

Minimize your context switching by interacting with your terminal directly from your browser.

tweety running from the browser

Features

Installation

Tweety is available on macOS, Linux.

# Homebrew (recommended)
brew install pomdtr/tap/tweety

or download a binary from releases.

If you want to compile it yourself, you can use the following command:

git clone https://github.com/pomdtr/tweety
cd tweety
make install

Usage

tweety <script-path>

By default, tweety will start on port 9999, so you can access it at http://localhost:9999.

You can use the --host and --port flags to change the host and port:

tweety --host 0.0.0.0 --port 8080 <script-path>

Any path or query parameter will be passed as arguments to the script.

  • http://localhost:9999/ssh/example.com will run the command <script-path> ssh example.com
  • http://localhost:9999/nvim?file=/home/pomdtr/.zshrc will run the command <script-path> nvim --file=/home/pomdtr/.zshrc

Make sure to properly parse and validate params in your entrypoint script.

Configuration

You can use @tweety.<name> directives to configure tweety from your script.

  • @tweety.theme <theme>: Set the theme for the terminal.
  • @tweety.themeDark <theme>: Set the dark theme for the terminal.
  • @tweety.favicon <url>: Set the favicon for the terminal.

Example entrypoint

#!/usr/bin/env -S deno run -A

// @tweety.theme Tomorrow
// @tweety.themeDark Tomorrow Night
// @tweety.favicon https://fav.farm/🔥

import { program } from 'npm:@commander-js/extra-typings'

async function runCommand(command: string, args?: string[]): Promise<number> {
    const cmd = new Deno.Command(command, { args });
    const process = cmd.spawn();
    const status = await process.status;
    return status.code
}

// url: http://localhost:9999/
program.name("tweety").action(async () => {
    Deno.exitCode = await runCommand("fish")
})

// url: http://localhost:9999/htop
program.command("htop").action(async () => {
    Deno.exitCode = await runCommand("htop");
})

// url: http://localhost:9999/ssh/example.com
program.command("ssh").argument("<host>").action(async (host: string) => {
    Deno.exitCode = await runCommand("ssh", [host]);
})

// url: http://localhost:9999/nvim?file=/path/to/file
program.command("edit").option("-f, --file <file>", "File to open in editor").action(async (options) => {
    Deno.exitCode = await runCommand("nvim", options.file ? [options.file] : []);
})

if (import.meta.main) {
    await program.parseAsync();
}

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL