From d3380c668a017cae893f085df6eb090fc5837212 Mon Sep 17 00:00:00 2001 From: cinco euzebio Date: Thu, 5 Mar 2026 20:24:13 -0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20fzf=20README=20preview=20wi?= =?UTF-8?q?th=20glow=20support?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Show README.md in the right 40% of the fzf picker on hover - Render with glow (CLICOLOR_FORCE=1 for colors in non-TTY pipe) when available, fall back to cat - Preview command uses sh -c for fish/zsh/bash compatibility - Bump version to 0.10.0 Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- CHANGELOG.md | 8 ++++++++ Cargo.lock | 20 ++++++++++---------- Cargo.toml | 2 +- README.md | 2 +- src/main.rs | 26 ++++++++++++++++++++++++++ 5 files changed, 46 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f47bcc..37398ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [0.10.0] - 2026-03-05 + +### Added +- fzf preview panel: hovering over a project shows its `README.md` in the right 40% of the screen +- Uses `glow` for rendered markdown when available, falls back to `cat` +- `CLICOLOR_FORCE=1` ensures glow outputs full ANSI colors even in fzf's non-TTY preview pipe +- Preview command runs via `sh -c '...' -- {}` for compatibility with fish, zsh, and bash + ## [0.9.2] - 2026-03-04 ### Changed diff --git a/Cargo.lock b/Cargo.lock index fd2148f..999d2d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -293,9 +293,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "139ef39800118c7683f2fd3c98c1b23c09ae076556b435f8e9064ae108aaeeec" +checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" dependencies = [ "cfg-if", "libc", @@ -570,18 +570,18 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.44" +version = "1.0.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" dependencies = [ "proc-macro2", ] [[package]] name = "r-efi" -version = "5.3.0" +version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" [[package]] name = "rand" @@ -809,7 +809,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "82a72c767771b47409d2345987fda8628641887d5466101319899796367354a0" dependencies = [ "fastrand", - "getrandom 0.4.1", + "getrandom 0.4.2", "once_cell", "rustix", "windows-sys 0.61.2", @@ -857,7 +857,7 @@ dependencies = [ [[package]] name = "tmuxido" -version = "0.9.2" +version = "0.10.0" dependencies = [ "anyhow", "clap", @@ -1133,9 +1133,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.7.14" +version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5364e9d77fcdeeaa6062ced926ee3381faa2ee02d3eb83a5c27a8825540829" +checksum = "df79d97927682d2fd8adb29682d1140b343be4ac0f08fd68b7765d9c059d3945" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index 339290a..76f2f4f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tmuxido" -version = "0.9.2" +version = "0.10.0" edition = "2024" [dev-dependencies] diff --git a/README.md b/README.md index 523fabf..f4fa9fd 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ A Rust-based tool to quickly find and open projects in tmux using fzf. No extern ## Features - Search for git repositories in configurable paths -- Interactive selection using fzf +- Interactive selection using fzf with live `README.md` preview (rendered via `glow` when available) - Native tmux session creation (no tmuxinator required!) - Support for project-specific `.tmuxido.toml` configs - Smart session switching (reuses existing sessions) diff --git a/src/main.rs b/src/main.rs index 1259f38..0cf0363 100644 --- a/src/main.rs +++ b/src/main.rs @@ -116,8 +116,34 @@ fn main() -> Result<()> { Ok(()) } +fn readme_preview_command() -> String { + let glow_available = Command::new("sh") + .args(["-c", "command -v glow"]) + .output() + .map(|o| o.status.success()) + .unwrap_or(false); + // CLICOLOR_FORCE=1 tells termenv (used by glow/glamour) to enable ANSI + // colors even when stdout is not a TTY (fzf preview runs in a pipe). + // Without it, glow falls back to bold-only "notty" style with no colors. + // Use `sh -c '...' -- {}` so the command runs in POSIX sh regardless of + // the user's $SHELL (fish, zsh, bash, etc.). + let viewer_cmd = if glow_available { + "CLICOLOR_FORCE=1 glow -s dark" + } else { + "cat" + }; + format!( + r#"sh -c 'readme="$1/README.md"; [ -f "$readme" ] && {viewer_cmd} "$readme" || echo "No README.md"' -- {{}}"# + ) +} + fn select_project_with_fzf(projects: &[PathBuf]) -> Result { + let preview_cmd = readme_preview_command(); let mut child = Command::new("fzf") + .arg("--preview") + .arg(&preview_cmd) + .arg("--preview-window") + .arg("right:40%") .stdin(Stdio::piped()) .stdout(Stdio::piped()) .spawn()