项目作者: bduggan

项目描述 :
A console for your console
高级语言: Raku
项目地址: git://github.com/bduggan/tmeta.git
创建时间: 2019-08-08T14:18:11Z
项目社区:https://github.com/bduggan/tmeta

开源协议:MIT License

下载


termie

A console for your console

SparrowCI

image

Description

termie (formerly tmeta) is a wrapper for tmux that supports
sending and receiving data to/from tmux panes.

Anything typed into the bottom pane is sent to the top one, but
lines that start with a backslash are commands for termie.
You can type \help to see all possible commands.

(To send a literal leading backslash, either start with a
space or start with a double backslash.)

Why

Because you get:

  • an uncluttered view of your commands separate from the output
  • a local history for commands that are run remotely
  • readline interface independent of the remote console
  • scripting support for programs that require a TTY
  • macros
  • the ability to monitor or capture output
  • other expect-like functionality
  • controlled copy-and-paste operations into remote sessions

Quick start

See below for installation.

There are a few different ways to start termie.

  1. Start tmux yourself, then have termie split a window and
    start up in its own pane:

    1. $ tmux
    2. $ termie
  2. Let termie start tmux for you:

    1. $ termie
  3. Run a termie script. This will split and run in another pane.

    1. $ tmux
    2. $ termie script.termie

I use the .termie suffix for my termie scripts. If you do too, you
might like this vim syntax file.

What do I use it with

termie plays well with REPLs, or any console based
application that uses a tty. For instance, docker, rails
console, interactive ruby shell, the python debugger, the
jupyter console, psql, mysql, regular ssh sessions, local
terminal sessions, whatever

More documentation

Please see the documentation for a complete list of commands.

Examples

Show a list of commands.

  1. > \help

Run date every 5 seconds until the output contains 02

  1. > date
  2. > \repeat
  3. > \await 02

Within a debugger session, send next every 2 seconds.

  1. > next
  2. > \repeat 2

Search the command history for the last occurrence of ‘User’ using fzf
(readline command history works too)

  1. > \find User

Search the output for “http”

  1. > \grep http

Send a local file named bigfile.rb to a remote rails console

  1. > \send bigfile.rb

Same thing, but throttle the copy-paste operation, sending 1 line per second:

  1. > \delay 1
  2. > \send bigfile.rb

Similar, but send it to an ssh console by first tarring and base64 encoding
and not echoing stdout, and note that ‘something’ can also be a directory:

  1. > \xfer something

Run a command locally, sending each line of output to the remote console:

  1. > \do echo date

Run a shell snippet locally, sending each line of output to the remote console:

  1. > \dosh for i in `seq 5`; do echo "ping host-$i"; done

Start printing the numbers 1 through 100, one per second, but send a ctrl-c
when the number 10 is printed:

  1. > \enq \stop
  2. queue is now : \stop
  3. > for i in `seq 100`; do echo $i; sleep 1; done
  4. # .. starts running in other pane ...
  5. > \await 10
  6. Waiting for "10"
  7. Then I will send:
  8. \stop
  9. Done: saw "10"
  10. starting enqueued command: \stop

Add an alias cat which cats a local file

  1. \alias cat \shell cat

Show a local file (do not send it to the other pane) using the above alias

  1. \cat myfile

Edit a file named session.rb, in ~/.termie/scripts

  1. \edit session.rb

After running the above, add this to session.rb:

  1. irb
  2. \expect irb(main):001:0>
  3. "hello world"
  4. \expect irb(main):002:0>
  5. exit

Now running

  1. \run session.rb

will start the interactive ruby console (irb) and the following
session should take place on the top panel:

  1. $ irb
  2. irb(main):001:0> "hello world"
  3. => "hello world"
  4. irb(main):002:0> exit
  5. $

Installation

Prerequisites: fzf, tmux, libreadline, raku and a few modules

  1. Install a recent version of Raku. The recommended way is to use rakubrew.

  2. Also install zef, the Raku package manager (rakubrew build-zef)

  3. Install fzf and tmux.
    (e.g. brew install fzf tmux on os/x)

  4. zef install https://github.com/bduggan/termie.git

See also