3 pointsby buckydigital5 hours ago1 comment
  • buckydigital5 hours ago
    In 1988 I wrote grabchars in C. It was last posted to comp.sources.misc in 1990. It reads raw keystrokes directly from the terminal — no Enter required — for use in shell scripts. But it was never really finished: BSD-only terminal APIs (sgtty.h), K&R C, broken on most platforms even then, and no real line editing. I posted it and then neglected it.

    grabchars 2.0 is the version it should have been. Rewritten in Rust, from scratch. Same CLI, but now actually portable (POSIX termios), with full line editing and Emacs keybindings, mask mode for positional input validation (phone numbers, dates, serial numbers with auto-inserted literals), filter-as-you-type selection menus, raw byte capture mode, and correct POSIX signal handling. All terminal I/O goes through libc::read directly — no terminal library.

    Shell scripts are hard to make interactive. grabchars is the primitive that changes that: single-keystroke capture, filter-as-you-type menus, positional input with auto-inserted literals, timeouts with defaults — each is one command where bash would need 5–10 lines of read gymnastics.

    Six ways to get it:

      # Pre-built binaries (macOS, Linux x86_64/aarch64/armv7)
      https://github.com/DanielSmith/grabchars/releases
    
      # Build from source
      git clone https://github.com/DanielSmith/grabchars
      cd grabchars && cargo build --release
    
      # Rust / crates.io
      cargo install grabchars
    
      # macOS (Homebrew)
      brew install DanielSmith/grabchars/grabchars
    
      # Arch Linux (AUR) — builds from source
      yay -S grabchars
    
      # Arch Linux (AUR) — pre-built binary
      yay -S grabchars-bin