### Manual installation and setup Source: https://github.com/tobi/try/blob/main/README.md Download the try script manually, make it executable, and configure your shell to use it. ```bash curl -sL https://raw.githubusercontent.com/tobi/try/refs/heads/main/try.rb > ~/.local/try.rb # Make "try" executable so it can be run directly chmod +x ~/.local/try.rb # Add to your shell (bash/zsh) echo 'eval "$(ruby ~/.local/try.rb init ~/src/tries)"' >> ~/.zshrc # for fish shell users echo '~/.local/try.rb init ~/src/tries | source' >> ~/.config/fish/config.fish ``` -------------------------------- ### Install via Homebrew Source: https://github.com/tobi/try/blob/main/docs/index.html Installs the try CLI using Homebrew by tapping the repository. ```bash brew tap tobi/try https://github.com/tobi/try && brew install try ``` -------------------------------- ### Install Try with Homebrew Source: https://github.com/tobi/try/blob/main/README.md Add the tap and install the Try package using Homebrew. ```bash brew tap tobi/try https://github.com/tobi/try brew install try ``` -------------------------------- ### Clone Repository Examples Source: https://github.com/tobi/try/blob/main/spec/command_line.md Various examples of cloning repositories using different URL formats and naming conventions. ```bash try clone https://github.com/tobi/try.git # Creates: 2025-11-30-tobi-try try clone https://github.com/user/repo myproject # Creates: 2025-11-30-myproject (custom name overrides) try https://github.com/tobi/try.git # URL shorthand (same as first example) try https://github.com/tobi/try/pull/124 # Clones the repository and checks out PR 124 # Creates: 2025-11-30-tobi-try try clone git@github.com:tobi/try.git # SSH URL also works: 2025-11-30-tobi-try try clone ssh://git@yourgitserver:port/user/repo.git # SSH URL with custom port also works: 2025-11-30-user-repo try clone deploy@git.example.com:src/team/project.git # SCP-style SSH URLs with nested paths also work: 2025-11-30-deploy-project ``` -------------------------------- ### Install try-cli Source: https://github.com/tobi/try/blob/main/docs/index.html Installs the try CLI tool via RubyGems. ```bash gem install try-cli ``` -------------------------------- ### Token Expansion Example Source: https://github.com/tobi/try/blob/main/spec/token_system.md Demonstrates the transformation of input strings containing tokens into formatted output. ```text Input: "Status: {b}OK{/b} - {dim}completed{/fg}" Output: "Status: [bold yellow]OK[reset] - [gray]completed[reset fg]" ``` -------------------------------- ### Try CLI Command Examples Source: https://github.com/tobi/try/blob/main/spec/command_line.md Common commands for initializing the shell environment, navigating projects, and managing git repositories. ```bash # Set up shell integration eval "$(try init)" # Interactive selector try # Selector with initial filter try project # Clone a repository try clone https://github.com/user/repo # Clone with custom name try clone https://github.com/user/repo my-fork # Create git worktree (from within a repo) try worktree feature-branch # Show version try --version # Show help try --help ``` -------------------------------- ### Install try init in shell configuration Source: https://github.com/tobi/try/blob/main/spec/init_spec.md Commands to add to shell configuration files to initialize the try tool on startup. ```bash eval "$(try init)" ``` ```zsh eval "$(try init)" ``` ```fish try init | source ``` -------------------------------- ### UI Element Formatting Source: https://github.com/tobi/try/blob/main/spec/token_system.md Examples of applying heading and query styling to UI components. ```text "{h1}Try Selector{reset}" "{dim}Query:{/fg} {b}user-input{/b}" ``` -------------------------------- ### Configure symbolic key sequences Source: https://github.com/tobi/try/blob/main/spec/test_spec.md Examples of using the symbolic format to navigate, type text, or cancel operations. ```bash # Navigate down, then up, then select --and-keys='CTRL-J,CTRL-K,ENTER' # Type text then select --and-keys='beta,ENTER' # Cancel with escape --and-keys='ESC' ``` -------------------------------- ### Example Deletion Script Output Source: https://github.com/tobi/try/blob/main/spec/delete_spec.md A complete example of the generated script for deleting two specific directories. ```sh # if you can read this, you didn't launch try from an alias. run try --help. cd '/home/user/tries' && \ test -d '2025-11-29-old-project' ]] && rm -rf '2025-11-29-old-project' && \ test -d '2025-11-28-abandoned' ]] && rm -rf '2025-11-28-abandoned' && \ cd '/home/user/code' 2>/dev/null || cd '/home/user/tries' ``` -------------------------------- ### Git repository cloning commands Source: https://github.com/tobi/try/blob/main/README.md Examples of cloning repositories using full commands, shorthand, and pull request URLs. ```bash # Clone with auto-generated directory name try clone https://github.com/tobi/try.git # Creates: 2025-08-27-tobi-try # Clone with custom name try clone https://github.com/tobi/try.git my-fork # Creates: my-fork # Shorthand syntax (no need to type 'clone') try https://github.com/tobi/try.git # Creates: 2025-08-27-tobi-try # Paste a GitHub pull request URL to clone and check out that PR try https://github.com/tobi/try/pull/124 # Creates: 2025-08-27-tobi-try ``` -------------------------------- ### Path Truncation Example Source: https://github.com/tobi/try/blob/main/spec/tui_spec.md Demonstrates the visual result of truncating a long path string with an ellipsis. ```text Full: "2025-11-29-very-long-project-name" Truncated: "2025-11-29-very-long-pro…" ``` -------------------------------- ### Search for experiments Source: https://github.com/tobi/try/blob/main/README.md Example output of the fuzzy search interface when searching for 'pool'. ```bash $ try pool β†’ 2025-08-14-redis-connection-pool 2h, 18.5 2025-08-03-thread-pool 3d, 12.1 2025-07-22-db-pooling 2w, 8.3 + Create new: pool ``` -------------------------------- ### Test pattern: Terminating keys Source: https://github.com/tobi/try/blob/main/spec/test_spec.md Examples of correct and incorrect ways to handle key termination in tests. ```bash # This will HANG - no Enter or Escape! output=$(try_run --path="$TEST_TRIES" --and-keys="beta" exec) ``` ```bash # Ends with Enter output=$(try_run --path="$TEST_TRIES" --and-keys="beta"$'\r' exec) # Or use --and-exit for render-only tests output=$(try_run --path="$TEST_TRIES" --and-exit --and-keys="beta" exec 2>&1) ``` -------------------------------- ### Line Layout Example 1: Short Name Source: https://github.com/tobi/try/blob/main/spec/tui_spec.md Visual representation of metadata positioning when sufficient space is available. ```text β†’ πŸ“ 2025-11-29-project just now, 5.2 β”‚ β”‚ β”‚ β”‚ β”‚ └─ path_end_pos = 24 β”‚ └─ col 79 (end) β”‚ └─ meta_start_pos = 66 └─ prefix (5 chars) available_space = 66 - 24 = 42 chars (> 2, show full metadata) ``` -------------------------------- ### Line Layout Example 2: Long Name Source: https://github.com/tobi/try/blob/main/spec/tui_spec.md Visual representation of metadata positioning with a long directory name. ```text β†’ πŸ“ 2025-11-30-this-is-a-very-long-directory-name-for-testing ow, 3.0 β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ └─ path_end_pos = 55 β”‚ β”‚ └─ col 79 β”‚ β”‚ └─ truncated from left └─ prefix (5 chars) └─ meta_start_pos = 72 available_space = 72 - 55 = 17 chars Full metadata = "just now, 3.0" (13 chars) Since 17 > 2, show full. But if name were longer... ``` -------------------------------- ### Execute TUI commands with raw escape sequences Source: https://github.com/tobi/try/blob/main/spec/test_spec.md Examples of using raw escape sequences within bash command substitution to automate TUI interactions. ```bash # Type "beta" then press Enter to select matching entry output=$(./try --path=/tmp/test --and-keys="beta"$'\r' exec 2>/dev/null) # Press Escape to cancel output=$(./try --path=/tmp/test --and-keys=$'\x1b' exec 2>/dev/null) # Navigate down twice, then up once, then select output=$(./try --path=/tmp/test --and-keys=$'\x1b[B\x1b[B\x1b[A\r' exec 2>/dev/null) # Type and delete with backspace output=$(./try --path=/tmp/test --and-keys="xyz"$'\x7f\x7f\x7f'"abc"$'\r' exec 2>/dev/null) # Use vim-style navigation (Ctrl-J down, Ctrl-K up) output=$(./try --path=/tmp/test --and-keys=$'\x0a\x0b\r' exec 2>/dev/null) ``` -------------------------------- ### Line Layout Example 4: Hidden Metadata Source: https://github.com/tobi/try/blob/main/spec/tui_spec.md Visual representation of metadata being hidden when the directory name is too long. ```text β†’ πŸ“ 2025-11-30-this-is-an-incredibly-long-name-that-fills-the-entire… β”‚ β”‚ β”‚ β”‚ └─ path_end_pos extends past where metadata would start └─ truncation ellipsis available_space < -metadata_len + 3, metadata completely hidden ``` -------------------------------- ### Line Layout Example 3: Very Long Name Source: https://github.com/tobi/try/blob/main/spec/tui_spec.md Visual representation of metadata truncation when the directory name encroaches on the metadata zone. ```text β†’ πŸ“ 2025-11-30-extremely-long-directory-name-that-takes-up-space w, 3.0 β”‚ β”‚ β”‚β”‚ β”‚ β”‚ └─ path_end_pos = 66 │└─────┴─ rightmost portion └─ prefix (5 chars) └─ only 13 chars available Full metadata = "just now, 3.0" (13 chars) available_space = 72 - 66 = 6 chars chars_to_skip = 1 - 6 = negative, but name extends into metadata zone Result: truncate "just no" from left, show "w, 3.0" ``` -------------------------------- ### Run Try with Nix Source: https://github.com/tobi/try/blob/main/README.md Execute the tool directly using Nix or initialize a new experiment directory. ```bash nix run github:tobi/try nix run github:tobi/try -- --help nix run github:tobi/try init ~/my-tries ``` -------------------------------- ### Compile and run native binary Source: https://github.com/tobi/try/blob/main/README.md Build a native binary version of try using Spinel and initialize it in your shell. ```bash make native SPINEL=/path/to/spinel # -O s, then strip ./dist/try --help eval "$(./dist/try init)" # wires the shell function to the binary, not MRI make native-test SPINEL=/path/to/spinel ``` -------------------------------- ### Configure Try via Home Manager Source: https://github.com/tobi/try/blob/main/README.md Integrate Try into a Nix Home Manager configuration. ```nix { inputs.try.url = "github:tobi/try"; imports = [ inputs.try.homeManagerModules.default ]; programs.try = { enable = true; path = "~/experiments"; # optional, defaults to ~/src/tries }; } ``` -------------------------------- ### Basic try CLI commands Source: https://github.com/tobi/try/blob/main/README.md Common commands for browsing experiments, creating worktrees, and cloning repositories. ```bash try # Browse all experiments try redis # Jump to redis experiment or create new try new api # Start with "2025-08-17-new-api" try . [name] # Create a dated worktree dir for current repo try ./path/to/repo [name] # Use another repo as the worktree source try worktree dir [name] # Same as above, explicit CLI form try clone https://github.com/user/repo.git # Clone repo into date-prefixed directory try https://github.com/user/repo.git # Shorthand for clone (same as above) try --help # See all options ``` -------------------------------- ### Combine CLI options Source: https://github.com/tobi/try/blob/main/spec/test_spec.md Demonstrates how to chain multiple flags to control path, exit behavior, and key injection. ```bash # Render with filter, capture output ./try --path=/tmp/test --and-exit --and-keys="beta" exec 2>&1 # Both inject keys AND render once (keys processed, then render, then exit) ./try --and-exit --and-keys="query" exec ``` -------------------------------- ### Initialize Try in Fish Source: https://github.com/tobi/try/blob/main/README.md Initialize the shell environment for Try in Fish. ```fish try init | source # or pick a path try init ~/src/tries | source ``` -------------------------------- ### Initialize Try in Bash/Zsh Source: https://github.com/tobi/try/blob/main/README.md Initialize the shell environment for Try in Bash or Zsh. ```bash # default is ~/src/tries eval "$(try init)" # or pick a path eval "$(try init ~/src/tries)" ``` -------------------------------- ### Initialize shell integration Source: https://github.com/tobi/try/blob/main/README.md Commands to initialize the try tool in Bash, Zsh, or Fish shells. ```bash # default is ~/src/tries eval "$(~/.local/try.rb init)" # or pick a path eval "$(~/.local/try.rb init ~/src/tries)" ``` ```fish ~/.local/try.rb init | source # or pick a path ~/.local/try.rb init ~/src/tries | source ``` -------------------------------- ### Command Line Synopsis Source: https://github.com/tobi/try/blob/main/spec/command_line.md Basic usage patterns for the try command. ```bash try [options] [command] [args...] try exec [options] [command] [args...] ``` -------------------------------- ### Create a New Experiment Source: https://github.com/tobi/try/blob/main/docs/index.html Creates a new experiment directory in the configured tries path. ```bash try cool-experiment ``` -------------------------------- ### Test pattern: Capturing output Source: https://github.com/tobi/try/blob/main/spec/test_spec.md Demonstrates how to correctly capture rendered output from the TUI. ```bash # --and-exit always exits with code 1 (cancelled), stdout is empty output=$(try_run --and-exit exec) # output will be empty! ``` ```bash output=$(try_run --and-exit exec 2>&1) # Redirect stderr to capture TUI ``` -------------------------------- ### Initialize Shell Integration Source: https://github.com/tobi/try/blob/main/docs/index.html Initializes the try CLI in your shell environment. Add this to your .zshrc or .bashrc file. ```bash eval "$(try init)" ``` -------------------------------- ### Verify wrapper functionality Source: https://github.com/tobi/try/blob/main/spec/init_spec.md Commands to test if the initialized wrapper correctly executes shell commands like directory changes. ```bash eval "$(try init)" try cd # Should launch selector and cd on selection ``` -------------------------------- ### Shell Integration Initialization Source: https://github.com/tobi/try/blob/main/spec/command_line.md Commands to initialize shell integration for bash, zsh, or fish. ```bash try init [path] ``` ```bash # bash/zsh eval "$(try init ~/src/tries)" # fish eval (try init ~/src/tries | string collect) ``` -------------------------------- ### Configure TRY_PATH environment variable Source: https://github.com/tobi/try/blob/main/README.md Set the storage location for experiments by defining the TRY_PATH environment variable. ```bash export TRY_PATH=~/code/sketches ``` -------------------------------- ### Truncation Algorithm with Formatting Tokens Source: https://github.com/tobi/try/blob/main/spec/tui_spec.md Demonstrates how the truncation algorithm handles formatting tokens by preserving them and counting only visible characters. ```text Input: "2025-11-29-{b}very{/b}-long-project-name" (29 visible chars) Max: 20 chars Output: "2025-11-29-{b}very{/b}-lon…" (19 visible + ellipsis) ``` -------------------------------- ### Script Component: Base Directory Change Source: https://github.com/tobi/try/blob/main/spec/delete_spec.md The initial command to switch to the base directory before performing deletions. ```sh cd '/path/to/tries' && \ ``` -------------------------------- ### Execute command in direct mode Source: https://github.com/tobi/try/blob/main/spec/command_line.md Direct mode executes commands immediately and provides a cd hint for the user to manually change directories. ```bash $ try clone https://github.com/user/repo Cloning into '/home/user/src/tries/2025-11-30-repo'/ cd '/home/user/src/tries/2025-11-30-repo' ``` -------------------------------- ### Interactive Directory Selection Source: https://github.com/tobi/try/blob/main/spec/command_line.md Commands for navigating or creating workspaces using the interactive TUI. ```bash try cd [query] try exec cd [query] try exec [query] # equivalent to: try exec cd [query] ``` -------------------------------- ### Fuzzy Match Highlighting Pattern Source: https://github.com/tobi/try/blob/main/spec/token_system.md Shows how to highlight matching characters in a string using bold tokens. ```text Input text: "2025-11-29-test" Query: "te" Rendered: "2025-11-29-{b}te{/b}st" Displayed: "2025-11-29-" + [bold yellow]"te"[reset] + "st" ``` -------------------------------- ### Validate init command output Source: https://github.com/tobi/try/blob/main/spec/init_spec.md Commands to verify that the generated shell syntax is valid for the target shell environment. ```bash # Test Bash syntax bash -n <(try init) # Test Fish syntax (if fish is available) fish -n <(SHELL=/usr/bin/fish try init) ``` -------------------------------- ### Clone Repository Commands Source: https://github.com/tobi/try/blob/main/spec/command_line.md Commands for cloning git repositories into dated directories. ```bash try clone [name] try exec clone [name] try [name] # URL shorthand (same as clone) ``` -------------------------------- ### Verify TUI render output with --and-exit Source: https://github.com/tobi/try/blob/main/spec/test_spec.md Captures the TUI render output to verify display formatting and content without entering an interactive loop. ```bash # Capture TUI render to check display output=$(./try --path=/tmp/test --and-exit exec 2>&1) # Verify score format is shown echo "$output" | grep -qE "[0-9]+\.[0-9]" ``` -------------------------------- ### Test pattern: Verify script selection Source: https://github.com/tobi/try/blob/main/spec/test_spec.md Validates that key injection results in the correct command script generation. ```bash output=$(try_run --path="$TEST_TRIES" --and-keys="query"$'\r' exec 2>/dev/null) if echo "$output" | grep -q "cd '"; then pass else fail "description" "cd command" "$output" "spec.md#section" fi ``` -------------------------------- ### Standard exec mode output format Source: https://github.com/tobi/try/blob/main/spec/command_line.md The expected output format for exec mode, using chained commands and a warning comment for direct execution. ```bash # if you can read this, you didn't launch try from an alias. run try --help. && \ cd '' ``` -------------------------------- ### --and-keys= Source: https://github.com/tobi/try/blob/main/spec/test_spec.md Injects a sequence of keystrokes into the TUI. The sequence must end in a terminating key (Enter, Escape, or Ctrl-C) to produce a deterministic result. ```APIDOC ## --and-keys= ### Description Injects a sequence of keystrokes as if typed by the user. The TUI processes these keys and exits when the sequence is exhausted or a terminating action occurs. ### Parameters - **sequence** (string) - Required - A comma-separated list of symbolic keys or raw escape sequences. Must end in a terminating key (Enter, Escape, or Ctrl-C). ### Usage Examples ```bash # Navigate down, then up, then select --and-keys='CTRL-J,CTRL-K,ENTER' # Type text then select --and-keys='beta,ENTER' # Cancel with escape --and-keys='ESC' ``` ``` -------------------------------- ### Alias try Command Source: https://github.com/tobi/try/blob/main/docs/index.html Creates a short alias for the try command to speed up workflow. ```bash alias t=try ``` -------------------------------- ### Implement UI interactions and easter eggs Source: https://github.com/tobi/try/blob/main/docs/index.html Handles clipboard copying, video loading states, scroll-based parallax effects, and a Konami code trigger for a rainbow animation. ```javascript // Copy code to clipboard function copyCode(btn) { const code = btn.previousElementSibling.textContent; navigator.clipboard.writeText(code).then(() => { btn.textContent = 'Copied!'; btn.classList.add('copied'); setTimeout(() => { btn.textContent = 'Copy'; btn.classList.remove('copied'); }, 2000); }); } document.addEventListener('DOMContentLoaded', () => { const video = document.getElementById('heroVideo'); const demoVideo = document.querySelector('.demo-video'); // Video loaded handler video.addEventListener('canplaythrough', () => { video.classList.add('loaded'); }); video.addEventListener('error', () => { console.log('Video not found - page works without it'); }); // Scroll reveal const observerOptions = { threshold: 0.15, rootMargin: '0px 0px -50px 0px' }; const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('visible'); } }); }, observerOptions); document.querySelectorAll('.stat-card, .feature-card').forEach(el => { observer.observe(el); }); // Parallax effect on hero let ticking = false; window.addEventListener('scroll', () => { if (!ticking) { requestAnimationFrame(() => { const scrollY = window.scrollY; const hero = document.querySelector('.hero'); const heroContent = document.querySelector('.hero-title'); if (scrollY < window.innerHeight) { heroContent.style.transform = `translateY(${scrollY * 0.2}px)`; } ticking = false; }); ticking = true; } }); // Easter egg: Konami code unlocks rainbow mode const konami = ['ArrowUp', 'ArrowUp', 'ArrowDown', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'ArrowLeft', 'ArrowRight', 'b', 'a']; let konamiIndex = 0; document.addEventListener('keydown', (e) => { if (e.key === konami[konamiIndex]) { konamiIndex++; if (konamiIndex === konami.length) { document.body.style.animation = 'rainbow 2s linear infinite'; konamiIndex = 0; } } else { konamiIndex = 0; } }); }); // Add rainbow animation const style = document.createElement('style'); style.textContent = ` @keyframes rainbow { 0% { filter: hue-rotate(0deg); } 100% { filter: hue-rotate(360deg); } } `; document.head.appendChild(style); ``` -------------------------------- ### Script Component: Per-item Deletion Source: https://github.com/tobi/try/blob/main/spec/delete_spec.md The command structure for checking and removing individual directories. ```sh test -d 'name' ]] && rm -rf 'name' && \ ``` -------------------------------- ### Git Worktree Commands Source: https://github.com/tobi/try/blob/main/spec/command_line.md Commands for creating git worktrees in dated directories. ```bash try worktree try exec worktree try . # Shorthand (requires name) ``` -------------------------------- ### Test pattern: Verify TUI rendering Source: https://github.com/tobi/try/blob/main/spec/test_spec.md Checks if the rendered output contains expected text using the try_run helper. ```bash output=$(try_run --path="$TEST_TRIES" --and-exit exec 2>&1) if echo "$output" | grep -q "expected text"; then pass else fail "description" "expected text" "$output" "spec.md#section" fi ``` -------------------------------- ### Display TUI List Section Source: https://github.com/tobi/try/blob/main/spec/tui_spec.md Visual representation of the dynamic list section showing project entries with timestamps and version numbers. ```text β†’ πŸ“ 2025-11-29-project just now, 5.2 πŸ“ 2025-11-28-another-project 2h ago, 3.1 πŸ“ 2025-11-27-old-thing 3d ago, 2.4 ``` -------------------------------- ### Fuzzy Matching Implementation in Ruby Source: https://github.com/tobi/try/blob/main/spec/fuzzy_matching.md Contains the core logic for processing entries, calculating fuzzy scores, and applying bonuses based on recency and word boundaries. ```ruby def process_entries(query, entries) entries.filter_map do |entry| has_date_prefix = entry.name =~ /^\d{4}-\d{2}-\d{2}-/ date_bonus = has_date_prefix ? 2.0 : 0.0 # No query - score by recency only if query.nil? || query.empty? tokenized = if has_date_prefix "{dim}#{entry.name[0..10]}{/fg}#{entry.name[11..]}" else entry.name end score = date_bonus + recency_bonus(entry.mtime) { path: entry.path, score: score, rendered: tokenized } else # Fuzzy matching result = fuzzy_match(entry.name, query) next nil unless result # No match fuzzy_score = result[:score] # Apply multipliers to fuzzy score only fuzzy_score *= query.length.to_f / (result[:last_match_pos] + 1) fuzzy_score *= 10.0 / (entry.name.length + 10.0) # Add contextual bonuses after multipliers final_score = fuzzy_score + date_bonus + recency_bonus(entry.mtime) { path: entry.path, score: final_score, rendered: result[:highlighted] } end end end def fuzzy_match(text, query) score = 0.0 last_match_pos = -1 highlighted = "" query_idx = 0 text.each_char.with_index do |char, pos| if query_idx < query.length && char.downcase == query[query_idx].downcase score += 1.0 # Base match # Word boundary bonus if pos == 0 || !text[pos - 1].match?(/[a-zA-Z0-9]/) score += 1.0 end # Proximity bonus if last_match_pos >= 0 gap = pos - last_match_pos - 1 score += 2.0 / Math.sqrt(gap + 1) end last_match_pos = pos query_idx += 1 highlighted += "{b}#{char}{/b}" else highlighted += char end end return nil if query_idx < query.length # Incomplete match { score: score, last_match_pos: last_match_pos, highlighted: highlighted } end def recency_bonus(mtime) hours = (Time.now - mtime) / 3600.0 3.0 / Math.sqrt(hours + 1) end ``` -------------------------------- ### Display TUI Header Layout Source: https://github.com/tobi/try/blob/main/spec/tui_spec.md Visual representation of the top-level header component containing the selector title and search input. ```text β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ πŸ“ Try Selector β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ > user query here β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` -------------------------------- ### Date Prefix Dimming Pattern Source: https://github.com/tobi/try/blob/main/spec/token_system.md Demonstrates de-emphasizing date prefixes using dim tokens. ```text Directory: "2025-11-29-project" Rendered: "{dim}2025-11-29-{/fg}project" Displayed: [gray]"2025-11-29-"[reset] + "project" ``` -------------------------------- ### Define TUI entry layout structure Source: https://github.com/tobi/try/blob/main/spec/tui_spec.md Visual representation of the directory entry layout, showing the alignment of primary and secondary components. ```text [β†’] [πŸ“] [directory-name.............] [timestamp, score] ^ ^ left-aligned right-aligned ``` -------------------------------- ### Generate Fish shell function Source: https://github.com/tobi/try/blob/main/spec/init_spec.md Defines the try function for the Fish shell, utilizing fish-specific syntax for command execution and evaluation. ```fish function try set -l out (/path/to/try exec --path '/default/tries/path' $argv 2>/dev/tty | string collect) if test $pipestatus[1] -eq 0 eval $out else echo $out end end ``` -------------------------------- ### Display TUI Footer Layout Source: https://github.com/tobi/try/blob/main/spec/tui_spec.md Visual representation of the bottom footer component displaying available keyboard commands. ```text β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ ↑↓: Navigate Enter: Select Ctrl-D: Delete Esc: Cancel β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` -------------------------------- ### Disable token expansion with --no-expand-tokens Source: https://github.com/tobi/try/blob/main/spec/test_spec.md Use this flag to output formatting tokens as literal text for verification purposes. ```bash ./try --no-expand-tokens --and-exit exec 2>&1 | grep "{b}" # Should find {b} tokens in output ``` -------------------------------- ### Fuzzy Matching Scoring Algorithm Source: https://github.com/tobi/try/blob/main/spec/performance.md A forward-only scoring algorithm that calculates match scores based on base points and proximity bonuses without backtracking. ```pseudocode For each character in query: Scan forward in target for match If found: score += base_points score += proximity_bonus / sqrt(gap + 1) Else: return 0 (no match) ``` -------------------------------- ### Disable ANSI colors with --no-colors Source: https://github.com/tobi/try/blob/main/spec/test_spec.md Useful for testing output in environments that do not support ANSI styling. ```bash output_colors=$(./try --and-exit exec 2>&1) output_plain=$(./try --no-colors --and-exit exec 2>&1) # output_colors should have ANSI codes, output_plain should not ``` -------------------------------- ### Test pattern: Verify exit code Source: https://github.com/tobi/try/blob/main/spec/test_spec.md Checks that specific key inputs trigger the expected exit code. ```bash try_run --path="$TEST_TRIES" --and-keys=$'\x1b' exec >/dev/null 2>&1 if [ $? -eq 1 ]; then pass else fail "ESC should exit with code 1" "exit 1" "exit $?" "spec.md#section" fi ``` -------------------------------- ### Script Component: PWD Restoration Source: https://github.com/tobi/try/blob/main/spec/delete_spec.md The command to restore the original working directory after the deletion process completes. ```sh cd '/original/pwd' 2>/dev/null || cd '/path/to/tries' ``` -------------------------------- ### Confirmation Dialog Prompt Source: https://github.com/tobi/try/blob/main/spec/delete_spec.md The visual prompt displayed to the user when confirming a batch deletion operation. ```text Delete X directories? - directory-1 - directory-2 - ... Type YES to confirm: ``` -------------------------------- ### Execute command in exec mode Source: https://github.com/tobi/try/blob/main/spec/command_line.md Exec mode outputs a shell script to stdout, intended to be evaluated by a shell alias to perform directory changes. ```bash $ try exec clone https://github.com/user/repo # if you can read this, you didn't launch try from an alias. run try --help. git clone 'https://github.com/user/repo' '/home/user/src/tries/2025-11-30-repo' && \ cd '/home/user/src/tries/2025-11-30-repo' ``` -------------------------------- ### Generate Bash/Zsh shell function Source: https://github.com/tobi/try/blob/main/spec/init_spec.md Defines the try function for POSIX-compatible shells to capture and evaluate output from the try binary. ```bash try() { local out out=$('/path/to/try' exec --path '/default/tries/path' "$@" 2>/dev/tty) if [ $? -eq 0 ]; then eval "$out" else echo "$out" fi } ``` -------------------------------- ### Delete Confirmation Dialog Layout Source: https://github.com/tobi/try/blob/main/spec/tui_spec.md Visual representation of the delete confirmation dialog displayed in the TUI. ```text Delete Directory Are you sure you want to delete: directory-name in /full/path/to/directory files: X files size: Y MB [YES] [NO] ``` -------------------------------- ### Override terminal dimensions for testing Source: https://github.com/tobi/try/blob/main/spec/test_spec.md Use these environment variables to simulate specific terminal sizes during execution. ```bash # Test with 400-character wide terminal TRY_WIDTH=400 ./try --path="$TEST_TRIES" --and-exit exec 2>&1 # Test narrow terminal TRY_WIDTH=40 TRY_HEIGHT=10 ./try --and-exit exec 2>&1 ``` -------------------------------- ### Disable Color Output in CLI Source: https://github.com/tobi/try/blob/main/spec/command_line.md Demonstrates how to suppress ANSI color codes using command-line flags or environment variables. ```bash # Using the flag try --no-colors --help # Using the environment variable NO_COLOR=1 try --help # Set globally in shell config export NO_COLOR=1 ``` -------------------------------- ### Generated Deletion Script Structure Source: https://github.com/tobi/try/blob/main/spec/delete_spec.md The template structure for the shell script generated during the delete operation. ```sh cd '/path/to/tries' && \ test -d 'dir-name-1' ]] && rm -rf 'dir-name-1' && \ test -d 'dir-name-2' ]] && rm -rf 'dir-name-2' && \ cd '/original/pwd' 2>/dev/null || cd '/path/to/tries' ``` -------------------------------- ### Delete Shell Script Structure Source: https://github.com/tobi/try/blob/main/spec/tui_spec.md The shell script structure generated by the TUI for executing recursive directory deletion. ```sh /usr/bin/env sh -c ' target=$(realpath "/path/to/dir"); base=$(realpath "/tries/base"); case "$target" in "$base/"*) ;; *) exit 1;; esac; case "$(pwd)/" in "$target/"*) cd "$base";; esac; rm -rf "$target" ' ``` -------------------------------- ### Calculate Final Fuzzy Match Score Source: https://github.com/tobi/try/blob/main/spec/fuzzy_matching.md The final score formula combining the fuzzy match score with density, length, and contextual bonuses. ```text final_score = (fuzzy_score Γ— density Γ— length) + date_bonus + recency_bonus ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.