Skip to content

Commit 6420e8f

Browse files
committed
Merge branch 'develop'
2 parents 5b20a6d + 674965a commit 6420e8f

4 files changed

Lines changed: 35 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.3.2] - 2026-04-10
9+
10+
### Fixed
11+
12+
- `pj --list` table no longer overflows the terminal width; paths are shortened with `~` and columns are truncated to fit
13+
814
## [0.3.1] - 2026-03-22
915

1016
### Fixed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pj-cli"
3-
version = "0.3.1"
3+
version = "0.3.2"
44
edition = "2021"
55
authors = ["Alberto Cebada Aleu <contact@albertocebada.com>"]
66
description = "Project launcher CLI with fuzzy matching"

src/commands/list.rs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
use std::path::Path;
2+
13
use anyhow::Result;
24
use chrono::{DateTime, Local, Utc};
3-
use tabled::{Table, Tabled};
5+
use crossterm::terminal;
6+
use tabled::{
7+
settings::{peaker::PriorityMax, Width},
8+
Table, Tabled,
9+
};
410

511
use crate::projects::ProjectStore;
612

@@ -18,6 +24,15 @@ struct ProjectRow {
1824
status: String,
1925
}
2026

27+
fn shorten_path(path: &Path) -> String {
28+
if let Some(home) = dirs::home_dir() {
29+
if let Ok(stripped) = path.strip_prefix(&home) {
30+
return format!("~/{}", stripped.display());
31+
}
32+
}
33+
path.display().to_string()
34+
}
35+
2136
pub fn run() -> Result<()> {
2237
let store = ProjectStore::load()?;
2338

@@ -36,7 +51,7 @@ pub fn run() -> Result<()> {
3651
.unwrap_or_else(|| "Unknown".to_string());
3752

3853
ProjectRow {
39-
path: p.path.display().to_string(),
54+
path: shorten_path(&p.path),
4055
tags: p.tags.join(", "),
4156
access_count: p.access_count,
4257
last_accessed: dt,
@@ -49,7 +64,16 @@ pub fn run() -> Result<()> {
4964
})
5065
.collect();
5166

52-
let table = Table::new(rows).to_string();
67+
let mut table = Table::new(rows);
68+
69+
if let Ok((width, _)) = terminal::size() {
70+
table.with(
71+
Width::truncate(width as usize)
72+
.suffix("..")
73+
.priority(PriorityMax::right()),
74+
);
75+
}
76+
5377
println!("{}", table);
5478

5579
Ok(())

0 commit comments

Comments
 (0)