Skip to content
egoistPublic

About

Rex terminal clone in MyGo native UI

Resources

Stars

117 stars

Watchers

0 watching

Forks

Repository files navigation

GoRex

A replica of Superlogical's Rex terminal, written in Go with MyGo's native UI and its terminal plugin (Ghostty's libghostty-vt). No webview, no cgo: one ~15 MB app.

GoRex

What it does

  • Tabs and split panes. Every pane is a card over the window's gradient, with its program's icon, name and directory in its header, and buttons to split right, split down, zoom and close. Drag the gaps between panes to resize them (double-click resets a split to half).
  • Persistent sessions. Shells run in a session server, a background process of the same binary (GoRex -server). Quit GoRex and everything keeps running; open it again and every tab, split and pane comes back as it was, programs still running. The server keeps each session's screen in a headless libghostty-vt emulator and sends a snapshot on attach, so full-screen programs (lazygit, vim, htop…) come back exactly.
  • Program activity. The server watches each terminal's foreground process (tcgetpgrp, sysctl, proc_pidinfo; on Windows, the shell's newest child, its command line and directory): headers and tabs name the program (Node, Git Changes for lazygit, Codex, SSH host…) and its working directory, a green dot shows a program printing, and an orange dot marks a pane whose program finished or rang the bell out of sight. When the window is in the background, a long command finishing posts a notification.
  • Tab icons stack the tiles of a tab's programs, the focused pane's in front, as Rex does. Tabs reorder by dragging, rename by double-click, and have a context menu.
  • Host chip with the machine's name and model; its popover shows the chip, memory, OS and the session server.
  • Command palette (⇧⌘P, Ctrl+Shift+P, or the ⌘ button): every command, and every pane to jump to, fuzzy-matched.
  • Light and dark appearances (View ▸ Appearance), text size (⌘+ ⌘− ⌘0), JetBrains Mono embedded.

Shortcuts

macOS Windows, Linux
⌘T Ctrl+Shift+T New tab
⌘D / ⇧⌘D Ctrl+Shift+D / Ctrl+Shift+E Split right / down
⌘W / ⇧⌘W Ctrl+Shift+W Close pane / tab
⇧⌘↩ Ctrl+Shift+Enter Zoom the pane
⌥⌘ arrows Alt+arrows Focus the pane in that direction
⌃⌘ arrows Alt+Shift+arrows Move the nearest divider
⌃⌘= Equalize panes
⌘1…⌘9, ⇧⌘[ ⇧⌘], ⌃Tab Ctrl+Shift+1…9, Ctrl+PageUp/PageDown, Ctrl+Tab Switch tabs
⇧⌘R Ctrl+Shift+R Rename tab
⇧⌘P, ⌘P Ctrl+Shift+P Command palette
⌘K Ctrl+Shift+K Clear
⌘+ ⌘− ⌘0 Ctrl+= Ctrl+- Ctrl+0 Text size
⌥⌘Q Quit and end all sessions

Elsewhere than on macOS, Control and a letter are the terminal's (Ctrl+C, Ctrl+D, Ctrl+W…), so GoRex's shortcuts take Shift too, as copying and pasting do (Ctrl+Shift+C, Ctrl+Shift+V), and none take Control and Alt, which type characters (AltGr) on many keyboards.

Develop and build

GoRex needs Go 1.27+ and MyGo 0.3.0, whose CLI go.mod pins as a tool:

go tool mygo dev     # GoRex Dev, rebuilt and restarted as the code changes
go test ./...        # the server, and the view without a window
go tool mygo build   # build/darwin-arm64/GoRex.app and a .dmg
go run ./tools/mkicon  # redraw resources/icon.png

go get -tool github.com/egoist/mygo/cmd/mygo@latest updates MyGo and its CLI together.

The app keeps its state in its data directory: the server's socket and log, layout.json and settings.json, in ~/Library/Application Support/GoRex for the built app and GoRex Dev for mygo dev's, so that developing never touches the sessions of the app you use (GOREX_DIR names another directory). The sessions outlive the app, but not a rebuild: a development build replaces a server that an older build started, ending its sessions, which then start again in the same directories.

Windows

GoRex runs on Windows 10 1809 or later, whose ConPTY runs the shells; its data directory is %AppData%\GoRex. Panes run $SHELL when it names a Windows program (nu, C:\Program Files\Git\bin\bash.exe), else PowerShell (pwsh, then powershell), else cmd. PowerShell's cd leaves its process's directory where it was, so GoRex starts it with a prompt that sets it, wrapping the profile's own prompt: the header then follows it, and new panes open there. The window is frameless and its title bar draws minimize, maximize and close with the other buttons; it resizes from its sides and bottom, not its top.

Layout

main.go the app, its window, and -server
state.go tabs, the tree of splits, panes, saving and restoring the layout
view.go, tabs.go, host.go, commands.go the interface: title bar, tabs, panes, host popover, menus and palette
programs.go how programs show: names, glyphs, tile colors
style.go, settings.go colors, fonts, terminal themes; appearance and text size
internal/rex the session server and its client: PTYs, foreground processes, headless screens, the socket protocol

Not replicated: Rex's connections to servers on other machines; GoRex's server listens on a local socket only.

Icons: Lucide (ISC) and Simple Icons (CC0). Font: JetBrains Mono (OFL).

About

Rex terminal clone in MyGo native UI

Resources

Stars

117 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages