This is a Go port of Tobi's try script - a tool for managing experiment directories with fuzzy search and smart organization.
My motivation for porting this originally came from the assumption that I would want to add a bunch of features that would be better suited to Go than Ruby, and also to work on some more Go stuff. But so far, the original features have been more than sufficient.
- Interactive TUI with fuzzy search and real-time filtering
- Smart scoring algorithm that considers:
- Fuzzy match quality
- Recently used directories (time-based scoring)
- Directory name length
- Date-prefixed directories get bonus points
- Git integration:
- Clone repositories into date-prefixed directories
- Create git worktrees from existing repositories
- Shell integration for Bash, Zsh, and Fish
- Zero dependencies (except for terminal handling library)
Important: This tool prints shell commands to stdout, which are then executed by a shell wrapper function. It does NOT directly create directories or execute git commands itself.
The workflow:
- You type
try redisin your shell - The shell wrapper calls
./try cd redis - The Go program prints:
mkdir -p ~/src/tries/2025-01-15-redis && touch ... && cd ... - The shell wrapper executes these commands
- Go 1.21 or later
- Unix-like system (macOS, Linux) with terminal support
git clone https://github.com/spmurrayzzz/try
cd try
go build -o bin/try try.goAdd to your ~/.zshrc or ~/.bashrc:
eval "$(./try init ~/src/tries)"For Fish shell, add to ~/.config/fish/config.fish:
eval (./try init ~/src/tries | string collect)try # Browse all experiments
try redis # Search for redis experiments
try clone <uri> # Clone git repository
try worktree dir # Create worktree from current directory
try init [path] # Generate shell function↑/↓orCtrl-P/N/J/K- NavigateEnter- Select or create directoryBackspace- Delete character from searchCtrl-D- Delete directory (with confirmation)ESC- Cancel- Type to filter/search
TRY_PATH- Override default directory (default:~/src/tries)
try # Type to search, select "Create new"
try my-experiment # Creates ~/src/tries/2025-01-15-my-experiment
try . my-name # From current git repo, creates worktree# Clone a repo into dated directory
try clone https://github.com/user/repo.git
# Create worktree from current repo
try worktree # Auto-named from current dir
try worktree . my-name # Custom name
# Create worktree from another repo
try worktree /path/to/repo custom-nameMake sure you've added the shell function to your profile and reloaded it:
source ~/.zshrc # or ~/.bashrcCheck that:
- You're in a git repository (
git statusworks) - You're using correct syntax:
try worktree . namenottry worktree name - The directory doesn't already exist
Ensure you're running in a terminal with TTY support. The tool requires an interactive terminal.
- Static typing: Uses Go's type system with
map[string]interface{}for flexibility - Error handling: More explicit error handling with proper error checks
- Terminal handling: Uses
golang.org/x/terminstead of Ruby'sio/console - Performance: Compiled binary is faster and has fewer runtime dependencies
- Symbols: Ruby symbols (
:cd,:mkdir) are replaced with strings ("cd","mkdir")
go run try.go test_try.gogo test -v# Set up test environment
export TRY_PATH=/tmp/test-tries
mkdir -p /tmp/test-tries
# Create test directories
mkdir -p /tmp/test-tries/2025-01-15-redis-test
mkdir -p /tmp/test-tries/2025-01-14-postgres-test
# Test interactive selector
./try cd --path /tmp/test-tries
# Test from git repo
./bin/try worktree . test-from-repoThe UI module implements double-buffered terminal output with:
- Token-based styling system (
{highlight},{dim_text}, etc.) - ANSI escape sequence handling
- TTY detection for graceful fallback
- Efficient screen updates (only redraws changed lines)
The scoring algorithm considers:
- Match quality: Character-by-character matching with proximity bonuses
- Time decay: Recently modified directories get higher scores
- Name length: Shorter names score higher for equivalent matches
- Date prefix: Directories with
YYYY-MM-DD-prefix get bonus points
Supports multiple Git URI formats:
https://github.com/user/repo.gitgit@github.com:user/repohttps://gitlab.com/user/repogit@host.com:user/repo
Automatically generates directory names like 2025-01-15-user-repo.
MIT License