Compare commits

...
6 Commits
Author SHA1 Message Date
cinco 3f72128a25 🔖 chore: bump version to 0.7.1 and update CHANGELOG
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2026-03-01 05:07:06 -03:00
cinco cc16cde540 📝 docs: add ASCII art previews for each available tmux layout in README 2026-03-01 05:07:03 -03:00
cinco db08840b64 🐛 fix: ask for layout in interactive wizard when window has multiple panes
Add `render_layout_prompt` and `parse_layout_input` to ui.rs so that
the first-run wizard asks the user to choose a tmux layout (1–5 or by
name) for each window that has 2 or more panes. Previously, layout was
always silently set to None.

Also update `render_config_created` to display the chosen layout in the
post-setup summary.

Closes: layout never being set during interactive setup
2026-03-01 05:07:00 -03:00
cinco 4ecdf96db8 📝 docs: update install URL to GitHub and fix default session description 2026-03-01 05:01:04 -03:00
cinco b05c188477 🐛 fix: consolidate publish-github into single shell block
continuous-integration/drone/push Build is failing
continuous-integration/drone/tag Build is passing
Multiple command blocks caused $RELEASE_ID to be lost between shells.
Using ${ARCH} with braces triggered Drone variable substitution before
the shell ran, resulting in an empty arch name. Fix: single | block
with all logic, iterate over full filenames (same pattern as publish),
and use ENVIRON["DRONE_TAG"] in awk to bypass Drone substitution.
2026-03-01 04:56:36 -03:00
cinco 75d66cd47c feat: publish releases to GitHub and update install source
- Self-update now queries the GitHub Releases API (parse_latest_tag extracted for testability)
- install.sh now fetches and downloads from GitHub Releases
- Drone CI release pipeline publishes to both Gitea and GitHub via GITHUB_TOKEN secret
- Bump version to 0.7.0
2026-03-01 04:50:52 -03:00
9 changed files with 295 additions and 31 deletions
+42
View File
@@ -109,3 +109,45 @@ steps:
depends_on: depends_on:
- build-x86_64 - build-x86_64
- build-aarch64 - build-aarch64
- name: publish-github
image: alpine
environment:
GITHUB_TOKEN:
from_secret: GITHUB_TOKEN
GITHUB_REPO: cinco/tmuxido
commands:
- apk add --no-cache curl jq
- |
EXISTING=$(curl -fsSL \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/$GITHUB_REPO/releases/tags/$DRONE_TAG" | jq -r '.id // empty')
if [ -n "$EXISTING" ]; then
curl -s -X DELETE \
-H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/$GITHUB_REPO/releases/$EXISTING"
fi
BODY=$(awk '
BEGIN { tag = ENVIRON["DRONE_TAG"] }
/^## \[/ { in_section = (index($0, "[" tag "]") > 0); next }
in_section && /^## \[/ { exit }
in_section { print }
' CHANGELOG.md)
RELEASE_ID=$(curl -fsSL -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
-H "Content-Type: application/json" \
"https://api.github.com/repos/$GITHUB_REPO/releases" \
-d "{\"tag_name\":\"$DRONE_TAG\",\"name\":\"$DRONE_TAG\",\"body\":$(echo "$BODY" | jq -Rs .)}" \
| jq -r '.id')
for FILE in tmuxido-x86_64-linux tmuxido-aarch64-linux; do
curl -fsSL -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/octet-stream" \
"https://uploads.github.com/repos/$GITHUB_REPO/releases/$RELEASE_ID/assets?name=$FILE" \
--data-binary @"$FILE"
done
depends_on:
- build-x86_64
- build-aarch64
+16
View File
@@ -4,6 +4,22 @@ 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/). The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [0.7.1] - 2026-03-01
### Fixed
- Interactive setup wizard now asks for a tmux layout when a window has 2 or more panes
- Layout selection shown in post-wizard summary
### Changed
- README: Added ASCII art previews for each available tmux layout
## [0.7.0] - 2026-03-01
### Changed
- `install.sh` now downloads from GitHub Releases
- Self-update now queries the GitHub Releases API for new versions
- Releases are published to both Gitea and GitHub
## [0.6.0] - 2026-03-01 ## [0.6.0] - 2026-03-01
### Added ### Added
Generated
+1 -1
View File
@@ -864,7 +864,7 @@ dependencies = [
[[package]] [[package]]
name = "tmuxido" name = "tmuxido"
version = "0.6.0" version = "0.7.1"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"clap", "clap",
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "tmuxido" name = "tmuxido"
version = "0.6.0" version = "0.7.1"
edition = "2024" edition = "2024"
[dev-dependencies] [dev-dependencies]
+57 -7
View File
@@ -30,7 +30,7 @@ A Rust-based tool to quickly find and open projects in tmux using fzf. No extern
## Installation ## Installation
```sh ```sh
curl -fsSL https://git.cincoeuzebio.com/cinco/Tmuxido/raw/branch/main/install.sh | sh curl -fsSL https://raw.githubusercontent.com/cinco/tmuxido/main/install.sh | sh
``` ```
Installs the latest release binary to `~/.local/bin/tmuxido`. On first run, the config file is created automatically at `~/.config/tmuxido/tmuxido.toml`. Installs the latest release binary to `~/.local/bin/tmuxido`. On first run, the config file is created automatically at `~/.config/tmuxido/tmuxido.toml`.
@@ -123,7 +123,7 @@ tmuxido --help
3. Presents them using fzf for selection 3. Presents them using fzf for selection
4. Creates or switches to a tmux session for the selected project 4. Creates or switches to a tmux session for the selected project
5. If a `.tmuxido.toml` config exists in the project, uses it to set up custom windows and panes 5. If a `.tmuxido.toml` config exists in the project, uses it to set up custom windows and panes
6. Otherwise, creates a default session with two windows: "editor" and "terminal" 6. Otherwise, uses the default session config from `~/.config/tmuxido/tmuxido.toml` (configured interactively on first run)
## Caching ## Caching
@@ -158,11 +158,61 @@ panes = []
### Available Layouts ### Available Layouts
- `main-horizontal` - Main pane on top, others below **`main-horizontal`** — Main pane on top, others below
- `main-vertical` - Main pane on left, others on right
- `tiled` - All panes tiled ```
- `even-horizontal` - All panes in horizontal row ┌──────────────────────┐
- `even-vertical` - All panes in vertical column │ │
│ main pane │
│ │
├──────────┬───────────┤
│ pane 2 │ pane 3 │
└──────────┴───────────┘
```
**`main-vertical`** — Main pane on left, others on right
```
┌─────────────┬────────┐
│ │ pane 2 │
│ main pane ├────────┤
│ │ pane 3 │
│ ├────────┤
│ │ pane 4 │
└─────────────┴────────┘
```
**`tiled`** — All panes tiled equally
```
┌───────────┬──────────┐
│ pane 1 │ pane 2 │
├───────────┼──────────┤
│ pane 3 │ pane 4 │
└───────────┴──────────┘
```
**`even-horizontal`** — All panes side by side
```
┌────────┬────────┬────────┐
│ │ │ │
│ pane 1 │ pane 2 │ pane 3 │
│ │ │ │
└────────┴────────┴────────┘
```
**`even-vertical`** — All panes stacked
```
┌──────────────────────┐
│ pane 1 │
├──────────────────────┤
│ pane 2 │
├──────────────────────┤
│ pane 3 │
└──────────────────────┘
```
### Panes ### Panes
+7 -4
View File
@@ -1,8 +1,9 @@
#!/bin/sh #!/bin/sh
set -e set -e
REPO="cinco/Tmuxido" REPO="cinco/tmuxido"
BASE_URL="https://git.cincoeuzebio.com" BASE_URL="https://github.com"
API_URL="https://api.github.com"
INSTALL_DIR="$HOME/.local/bin" INSTALL_DIR="$HOME/.local/bin"
arch=$(uname -m) arch=$(uname -m)
@@ -12,8 +13,10 @@ case "$arch" in
*) echo "Unsupported architecture: $arch" >&2; exit 1 ;; *) echo "Unsupported architecture: $arch" >&2; exit 1 ;;
esac esac
tag=$(curl -fsSL "$BASE_URL/api/v1/repos/$REPO/releases?limit=1&page=1" \ tag=$(curl -fsSL \
| grep -o '"tag_name":"[^"]*"' | head -1 | cut -d'"' -f4) -H "Accept: application/vnd.github.v3+json" \
"$API_URL/repos/$REPO/releases/latest" \
| grep -o '"tag_name":"[^"]*"' | cut -d'"' -f4)
[ -z "$tag" ] && { echo "Could not fetch latest release" >&2; exit 1; } [ -z "$tag" ] && { echo "Could not fetch latest release" >&2; exit 1; }
+21 -2
View File
@@ -181,14 +181,19 @@ impl Config {
window_names window_names
}; };
// Configure panes for each window // Configure panes and layout for each window
let mut windows = Vec::new(); let mut windows = Vec::new();
for name in names { for name in names {
let panes = Self::prompt_for_panes(&name)?; let panes = Self::prompt_for_panes(&name)?;
let layout = if panes.len() > 1 {
ui::render_layout_prompt(&name, panes.len())?
} else {
None
};
windows.push(crate::session::Window { windows.push(crate::session::Window {
name, name,
panes, panes,
layout: None, layout,
}); });
} }
@@ -348,6 +353,20 @@ mod tests {
assert_eq!(result, vec!["editor", "terminal", "server"]); assert_eq!(result, vec!["editor", "terminal", "server"]);
} }
#[test]
fn should_use_ui_parse_functions_for_layout() {
assert_eq!(ui::parse_layout_input(""), None);
assert_eq!(
ui::parse_layout_input("1"),
Some("main-horizontal".to_string())
);
assert_eq!(
ui::parse_layout_input("main-vertical"),
Some("main-vertical".to_string())
);
assert_eq!(ui::parse_layout_input("invalid"), None);
}
#[test] #[test]
fn should_parse_config_with_windows_and_panes() { fn should_parse_config_with_windows_and_panes() {
let toml_str = r#" let toml_str = r#"
+39 -16
View File
@@ -3,8 +3,9 @@ use std::os::unix::fs::PermissionsExt;
use std::path::PathBuf; use std::path::PathBuf;
use std::process::Command; use std::process::Command;
const REPO: &str = "cinco/Tmuxido"; const REPO: &str = "cinco/tmuxido";
const BASE_URL: &str = "https://git.cincoeuzebio.com"; const BASE_URL: &str = "https://github.com";
const API_BASE: &str = "https://api.github.com";
/// Check if running from cargo (development mode) /// Check if running from cargo (development mode)
fn is_dev_build() -> bool { fn is_dev_build() -> bool {
@@ -26,12 +27,27 @@ fn detect_arch() -> Result<&'static str> {
} }
} }
/// Fetch latest release tag from Gitea API /// Parse tag_name from a GitHub releases/latest JSON response
fn parse_latest_tag(response: &str) -> Result<String> {
let tag: serde_json::Value =
serde_json::from_str(response).context("Failed to parse release API response")?;
tag.get("tag_name")
.and_then(|t| t.as_str())
.map(|t| t.to_string())
.ok_or_else(|| anyhow::anyhow!("Could not extract tag_name from release"))
}
/// Fetch latest release tag from GitHub API
pub(crate) fn fetch_latest_tag() -> Result<String> { pub(crate) fn fetch_latest_tag() -> Result<String> {
let url = format!("{}/api/v1/repos/{}/releases?limit=1&page=1", BASE_URL, REPO); let url = format!("{}/repos/{}/releases/latest", API_BASE, REPO);
let output = Command::new("curl") let output = Command::new("curl")
.args(["-fsSL", &url]) .args([
"-fsSL",
"-H",
"Accept: application/vnd.github.v3+json",
&url,
])
.output() .output()
.context("Failed to execute curl. Make sure curl is installed.")?; .context("Failed to execute curl. Make sure curl is installed.")?;
@@ -42,17 +58,7 @@ pub(crate) fn fetch_latest_tag() -> Result<String> {
)); ));
} }
let response = String::from_utf8_lossy(&output.stdout); parse_latest_tag(&String::from_utf8_lossy(&output.stdout))
// Parse JSON response to extract tag_name
let tag: serde_json::Value =
serde_json::from_str(&response).context("Failed to parse release API response")?;
tag.get(0)
.and_then(|r| r.get("tag_name"))
.and_then(|t| t.as_str())
.map(|t| t.to_string())
.ok_or_else(|| anyhow::anyhow!("Could not extract tag_name from release"))
} }
/// Get path to current executable /// Get path to current executable
@@ -211,6 +217,23 @@ mod tests {
); );
} }
#[test]
fn should_parse_tag_from_github_latest_release_response() {
let json = r#"{"tag_name":"0.7.0","name":"0.7.0","body":"release notes"}"#;
assert_eq!(parse_latest_tag(json).unwrap(), "0.7.0");
}
#[test]
fn should_return_error_when_tag_name_missing() {
let json = r#"{"name":"0.7.0","body":"no tag_name field"}"#;
assert!(parse_latest_tag(json).is_err());
}
#[test]
fn should_return_error_when_response_is_invalid_json() {
assert!(parse_latest_tag("not valid json").is_err());
}
#[test] #[test]
fn should_compare_versions_correctly() { fn should_compare_versions_correctly() {
assert_eq!( assert_eq!(
+111
View File
@@ -133,6 +133,12 @@ pub fn render_config_created(
println!("{}", label_style.render(" 🪟 Default Windows:")); println!("{}", label_style.render(" 🪟 Default Windows:"));
for window in windows { for window in windows {
println!(" {}", window_style.render(&format!("{}", window.name))); println!(" {}", window_style.render(&format!("{}", window.name)));
if let Some(layout) = &window.layout {
println!(
"{}",
info_style.render(&format!(" └─ layout: {}", layout))
);
}
if !window.panes.is_empty() { if !window.panes.is_empty() {
for (i, pane) in window.panes.iter().enumerate() { for (i, pane) in window.panes.iter().enumerate() {
let pane_display = if pane.is_empty() { let pane_display = if pane.is_empty() {
@@ -299,6 +305,67 @@ pub fn render_panes_prompt(window_name: &str) -> Result<String> {
Ok(input.trim().to_string()) Ok(input.trim().to_string())
} }
/// Renders a prompt for the layout of a window with multiple panes
pub fn render_layout_prompt(window_name: &str, pane_count: usize) -> Result<Option<String>> {
let prompt_style = Style::new().bold(true).foreground(color_green());
let hint_style = Style::new().italic(true).foreground(color_dark_gray());
let window_style = Style::new().bold(true).foreground(color_purple());
let label_style = Style::new().foreground(color_blue());
println!();
println!(
" Layout for window {} ({} panes):",
window_style.render(window_name),
label_style.render(&pane_count.to_string())
);
println!(
"{}",
hint_style.render(" Choose a pane layout (leave empty for no layout):")
);
println!(
"{}",
hint_style.render(" 1. main-horizontal — main pane on top, others below")
);
println!(
"{}",
hint_style.render(" 2. main-vertical — main pane on left, others on right")
);
println!(
"{}",
hint_style.render(" 3. tiled — all panes tiled equally")
);
println!(
"{}",
hint_style.render(" 4. even-horizontal — all panes side by side")
);
println!(
"{}",
hint_style.render(" 5. even-vertical — all panes stacked vertically")
);
print!(" {} ", prompt_style.render(" Layout (1-5 or name):"));
io::stdout().flush().context("Failed to flush stdout")?;
let mut input = String::new();
io::stdin()
.read_line(&mut input)
.context("Failed to read input")?;
Ok(parse_layout_input(input.trim()))
}
/// Parse layout input: accepts number (1-5) or layout name; returns None for empty/invalid
pub fn parse_layout_input(input: &str) -> Option<String> {
match input.trim() {
"" => None,
"1" | "main-horizontal" => Some("main-horizontal".to_string()),
"2" | "main-vertical" => Some("main-vertical".to_string()),
"3" | "tiled" => Some("tiled".to_string()),
"4" | "even-horizontal" => Some("even-horizontal".to_string()),
"5" | "even-vertical" => Some("even-vertical".to_string()),
_ => None,
}
}
/// Renders a prompt for a pane command /// Renders a prompt for a pane command
pub fn render_pane_command_prompt(pane_name: &str) -> Result<String> { pub fn render_pane_command_prompt(pane_name: &str) -> Result<String> {
let prompt_style = Style::new().bold(true).foreground(color_green()); let prompt_style = Style::new().bold(true).foreground(color_green());
@@ -531,6 +598,50 @@ mod tests {
render_config_created(&vec!["~/Projects".to_string()], 5, true, 24, &windows); render_config_created(&vec!["~/Projects".to_string()], 5, true, 24, &windows);
} }
#[test]
fn should_return_none_for_empty_layout_input() {
assert_eq!(parse_layout_input(""), None);
assert_eq!(parse_layout_input(" "), None);
}
#[test]
fn should_parse_layout_by_number() {
assert_eq!(parse_layout_input("1"), Some("main-horizontal".to_string()));
assert_eq!(parse_layout_input("2"), Some("main-vertical".to_string()));
assert_eq!(parse_layout_input("3"), Some("tiled".to_string()));
assert_eq!(parse_layout_input("4"), Some("even-horizontal".to_string()));
assert_eq!(parse_layout_input("5"), Some("even-vertical".to_string()));
}
#[test]
fn should_parse_layout_by_name() {
assert_eq!(
parse_layout_input("main-horizontal"),
Some("main-horizontal".to_string())
);
assert_eq!(
parse_layout_input("main-vertical"),
Some("main-vertical".to_string())
);
assert_eq!(parse_layout_input("tiled"), Some("tiled".to_string()));
assert_eq!(
parse_layout_input("even-horizontal"),
Some("even-horizontal".to_string())
);
assert_eq!(
parse_layout_input("even-vertical"),
Some("even-vertical".to_string())
);
}
#[test]
fn should_return_none_for_invalid_layout_input() {
assert_eq!(parse_layout_input("6"), None);
assert_eq!(parse_layout_input("0"), None);
assert_eq!(parse_layout_input("unknown"), None);
assert_eq!(parse_layout_input("horizontal"), None);
}
#[test] #[test]
fn render_config_created_with_disabled_cache_should_not_panic() { fn render_config_created_with_disabled_cache_should_not_panic() {
let windows = vec![Window { let windows = vec![Window {