opensesame
A cross-platform Rust library for opening files in text editors with line:column positioning support.
Features
- Cross-platform: Works on macOS, Linux, and Windows
- Smart editor detection: Finds editors via
$VISUAL,$EDITOR, or PATH search - Line:column positioning: Opens files at specific locations when supported
- Comprehensive editor support: 25+ editors including VS Code, Vim, NeoVim, Emacs, Sublime Text, Zed, Helix, Cursor, Windsurf, JetBrains IDEs, and more
- Ergonomic API: Simple functions and builder pattern for flexibility
- Type-safe errors: Rich error types for proper error handling
Installation
[]
= "0.1"
Quick Start
use Editor;
// Open a file in the default editor
open?;
// Open at a specific line (1-indexed)
open_at?;
// Open at a specific line and column
open_at_position?;
Builder API
For more control, use the builder pattern:
use ;
builder
.file
.line
.column
.wait // Wait for editor to close
.open?;
// Specify a particular editor
builder
.file
.editor
.line
.open?;
// Or by binary name
builder
.file
.editor_binary
.line
.open?;
Supported Editors
| Editor | Binary | Line | Column | Wait |
|---|---|---|---|---|
| VS Code | code |
✓ | ✓ | ✓ |
| VS Code Insiders | code-insiders |
✓ | ✓ | ✓ |
| VSCodium | codium |
✓ | ✓ | ✓ |
| Cursor | cursor |
✓ | ✓ | ✓ |
| Windsurf | windsurf |
✓ | ✓ | ✓ |
| Vim | vim |
✓ | ✓ | - |
| NeoVim | nvim |
✓ | ✓ | - |
| Emacs | emacs |
✓ | ✓ | ✓ |
| Sublime Text | subl |
✓ | ✓ | ✓ |
| Zed | zed |
✓ | ✓ | ✓ |
| Helix | hx |
✓ | ✓ | - |
| Nano | nano |
✓ | ✓ | - |
| TextMate | mate |
✓ | - | ✓ |
| Notepad++ | notepad++ |
✓ | ✓ | - |
| Kate | kate |
✓ | ✓ | - |
| Atom | atom |
✓ | ✓ | ✓ |
| IntelliJ IDEA | idea |
✓ | - | ✓ |
| WebStorm | webstorm |
✓ | - | ✓ |
| PyCharm | pycharm |
✓ | - | ✓ |
| GoLand | goland |
✓ | - | ✓ |
| CLion | clion |
✓ | - | ✓ |
| Xcode | xed |
✓ | - | ✓ |
Editor Detection
opensesame detects your preferred editor in this order:
$VISUALenvironment variable (preferred for GUI editors)$EDITORenvironment variable (traditional editor variable)- Search PATH for known editors (VS Code, Cursor, Zed, nvim, vim, etc.)
The environment variables can include arguments:
Error Handling
opensesame provides rich error types:
use ;
match open
License
MIT