Skip to content

Repository files navigation

PowerShell 7+ Cross-platform SSH / xterm-256color Pester 5 Experimental MIT License


Important

babae is currently in an experimental state. While it is designed to be a lightweight and efficient editor, it is not yet fully stable. Please be aware that bugs may occur, and there is a risk of file corruption when editing. It is recommended to use it on non-critical files and keep backups.


Introduction

babae is a zero-dependency TUI text editor written in pure PowerShell. No NuGet packages, no compiled DLLs, no external binaries — just a single .ps1 file you can drop anywhere and run. It renders via raw ANSI escape sequences, handles input via bracketed paste mode (BPM), and speaks .editorconfig.

Its primary reason for existence: most terminal editors misbehave when pasting indented text over SSH in Bitvise (xterm-256color). babae fixes that at the input layer.

Key Features

  • Zero Dependencies: One file. pwsh ./babae.ps1. Done.
  • SSH-Safe Paste: Bracketed paste mode (BPM) support across both interactive and redirected stdin paths. Right-click paste over SSH does not staircase — ever. See The Staircase Paste Fix.
  • ANSI TUI Rendering: Low-flicker frame rendering via a shadow row buffer and direct stdout stream writes. Only changed rows are redrawn.
  • Five Built-in Themes: babae dark, Catppuccin Mocha, Catppuccin Frappe, GitHub Dark, Catppuccin Latte (high contrast). Cycle with ^T.
  • Undo / Redo: Snapshot-based undo stack (up to 200 entries) with ^Z / ^Y.
  • Incremental Search: Live highlighting across the buffer with ^F.
  • Cross-Platform Clipboard: ^C / ^V via xclip / xsel / wl-copy on Linux (X11 and Wayland), pbcopy / pbpaste on macOS, System.Windows.Forms.Clipboard on Windows.
  • .editorconfig Support: Picks up indent_style, indent_size, end_of_line, trim_trailing_whitespace, insert_final_newline, and charset from the nearest .editorconfig.
  • Mouse Right-Click Paste on Windows: Win32 console API integration for native right-click paste events.
  • Language Detection: Automatic language label in the header based on file extension (see Language Detection).
  • Global Install: On first run outside ~/.babae/, babae offers to install itself globally and register a babae shell function in your PowerShell profile.

Environment Setup Guide

1. Install PowerShell 7+

babae requires PowerShell 7 or later.

2. Download babae

curl -O https://gitlab.com/simwai/babae/-/raw/main/babae.ps1

That is the entire installation.

2b. Install via winget (Windows)

winget install simwai.babae

The portable package contains the launcher, babae.ps1, and LICENSE. It requires PowerShell 7+ on PATH.

See WINGET.md for package publishing and CI setup.

Global Install

On first run, if babae detects it is not already running from ~/.babae/babae.ps1, it will prompt:

babae is not installed globally. Install to ~/.babae/babae.ps1 and add to profile? (y/n):

Answering y copies babae.ps1 to ~/.babae/ and appends a babae function to your $PROFILE, so you can launch it from anywhere with:

babae myfile.txt

If a different version is already installed, the same prompt appears offering to update it. Set $Env:BABAE_SKIP_INSTALL = 1 to suppress this check entirely.

Usage Guide

# Open a new buffer
pwsh ./babae.ps1

# Open an existing file
pwsh ./babae.ps1 myfile.txt

# Open with a specific theme
pwsh ./babae.ps1 myfile.txt -Theme mocha

Keybindings

Key Action
^S Save
^Q Quit
^Z Undo
^Y Redo
^F Find (incremental search)
^A Select all
^C Copy selection (or current line)
^V Paste from clipboard
^T Cycle theme
^F1 Help
Arrow keys Move cursor
Shift+Arrows Extend selection
Home / End Start / end of line
PgUp / PgDn Scroll by screen
Backspace / Del Delete character
Enter New line
Tab Insert indent / autocomplete
Esc Cancel search / clear selection
RightClick Paste from clipboard (Windows only)

Themes

Flag value Name
dark (default) babae dark
mocha Catppuccin Mocha
frappe Catppuccin Frappe
github-dark GitHub Dark
latte-contrast Catppuccin Latte (high contrast)

Language Detection

babae automatically displays a language label in the header bar based on the opened file's extension. No configuration needed.

Extension(s) Language
.ps1, .psm1, .psd1 PowerShell
.cs C#
.ts, .tsx TypeScript
.js, .jsx JavaScript
.py Python
.json, .jsonc, .jsonl JSON / JSONC
.md Markdown
.sh, .bash Bash
.html, .htm HTML
.css CSS
.svg SVG
.yaml, .yml YAML
.toml TOML
.java Java
.env / *.env dotenv
Dockerfile Dockerfile
(anything else) Plain Text

The Staircase Paste Fix

babae solves the "Staircase" bug (compound auto-indentation) using Bracketed Paste Mode (BPM).

For a deep dive into the anatomy of the bug and the technical implementation of the fix, see: 👉 STAIRCASE.md

Deep Dive: The Theory of the Terminal

To understand the core architecture of babae, the .NET/PowerShell APIs used, and the ANSI specifications it follows, check out the comprehensive theory guide: 👉 THEORY.md

Testing

E2E tests use Pester 5 with no Docker. Each test starts babae as a child process with stdin/stdout fully redirected, writes raw byte sequences to stdin, and verifies the output file.

# Install Pester (once)
Install-Module -Name Pester -MinimumVersion 5.0 -Force -Scope CurrentUser

# Run the suite
Invoke-Pester ./babae.tests.ps1 -Output Detailed

The suite covers:

  • BPM byte-sequence helper unit tests
  • Staircase regression: uniform indent, mixed indent, empty paste, 500-line large paste
  • Normal key input: printable chars, Enter auto-indent, Ctrl+Z undo/redo
  • Ctrl+V clipboard paste path isolation

About

Highly experimental, quick and dirty try to generate a PowerShell-based code editor

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Used by

Contributors

Languages