Pure Ruby terminal emulator core
Features · Installation · Quick Start · PTY Sessions · Command History · Shell Integration
Tarazed is a pure Ruby terminal emulator core. It provides the terminal cell grid, scrollback, VT parser, keyboard/mouse encoding, and a POSIX or Windows ConPTY session without depending on an editor or UI toolkit.
- Unicode-aware cell grid with bounded scrollback
- Chunk-safe VT parsing for terminal controls, input, links, and selection
- Keyboard, mouse, bracketed-paste, and terminal-reply encoding
- POSIX PTY and 64-bit Windows ConPTY sessions behind one API
- OSC 133 command history and OSC 7 working-directory tracking
- Packaged shell integration for bash, zsh, and fish
bundle add tarazedOr run gem install tarazed.
Tarazed supports Ruby 3.1 and later.
Feed arbitrary byte chunks into a VT; incomplete UTF-8 and control sequences
are retained until the next chunk.
require "tarazed"
screen = Tarazed::Grid.new(columns: 80, rows: 24)
terminal = Tarazed::VT.new(screen)
terminal.feed("\e[32mready\e[0m\r\n")
puts screen.textTarazed::PTY owns a child process and feeds its output into the same grid.
It uses a POSIX PTY on macOS and Linux and ConPTY on 64-bit Windows:
terminal = Tarazed::PTY.new(command: ["/bin/sh"], columns: 80, rows: 24)
terminal.write("printf 'hello\\n'\r")
terminal.read(timeout: 0.1)
puts terminal.status.exitstatus if !terminal.alive? && terminal.status
terminal.closeConPTY requires a supported 64-bit Windows release and does not fall back to a
pipe-only console. After natural process exit, status provides exited?,
exitstatus, success?, and termsig on every platform.
Tarazed::Session adds a pump-oriented API and bounded OSC 133 command
history. Command rows and output ranges use stable absolute history rows, and
OSC 7 updates the session working directory:
session = Tarazed::Session.new(command: ["/bin/bash"], columns: 80, rows: 24)
session.pump(timeout: 0.05)
session.commands.each do |command|
puts "#{command.exit_status}: #{command.input} (#{command.cwd})"
end
session.closeShell integration snippets for bash, zsh, and fish are packaged with the gem.
An embedding application can inject one into a new interactive shell with
Tarazed::ShellIntegration.read(:bash) (or :zsh / :fish). The snippets
emit prompt, input, execution, and completion markers without changing the
visible prompt.
bundle install
bundle exec rake test
bundle exec rbs -I sig validate
BUDGET=1 bundle exec rake bench
gem build --strict tarazed.gemspecBug reports and pull requests are welcome at https://github.com/noxdea/tarazed.
Tarazed is available under the MIT License.