Yeesh.Live.TerminalComponent (Yeesh v0.8.1)

View Source

LiveView component that renders an interactive terminal in the browser.

Usage

<.live_component
  module={Yeesh.Live.TerminalComponent}
  id="my-terminal"
  commands={[MyApp.Commands.Deploy]}
  prompt="app> "
  theme={:dark}
  context={%{user_id: @current_user.id}}
/>

Assigns

  • :id (required) - unique identifier for this terminal instance
  • :commands - list of command modules to register (default: [])
  • :builtins - which built-in commands to register (default: :help). Accepted values: :all, :none, :help, or a list of builtin modules.
  • :prompt - prompt string (default: "$ ")
  • :theme - terminal theme (default: :default)
  • :welcome_message - welcome message (default: the Yeesh welcome message)
  • :resize_event - CustomEvent name to dispatch on resize to fit if defined (default: nil)
  • :context - arbitrary map passed through to commands (default: %{})
  • :session_opts - additional session options (default: [])
  • :sandbox_opts - Dune sandbox configuration (default: [])

Events

The component communicates with the JS hook via push_event/handle_event:

  • "yeesh:input" - user submitted a command line
  • "yeesh:complete" - tab completion request
  • "yeesh:history_prev" - up arrow / Ctrl+P
  • "yeesh:history_next" - down arrow / Ctrl+N
  • "yeesh:history_search" - Ctrl+R reverse incremental search
  • "yeesh:interrupt" - Ctrl+C
  • "yeesh:output" - pushed to client with command output
  • "yeesh:completion" - pushed to client with completions
  • "yeesh:search_result" - pushed to client with search match
  • "yeesh:prompt" - pushed to client with new prompt

Summary

Functions

xterm_style(assigns)

yeesh-terminal-element(assigns)