From 3ecac46c943417ca7240d907dd282633fc41f2a1 Mon Sep 17 00:00:00 2001 From: Alexander Akhmetov Date: Thu, 15 Jan 2026 13:24:15 +0100 Subject: [PATCH] feat: Add TICKET_PAGER support --- CHANGELOG.md | 1 + ticket | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8cc817..cab3f12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Added - `list` command alias for `ls` +- `TICKET_PAGER` environment variable for `show` command (only when stdout is a TTY; falls back to `PAGER`) ### Changed - Walk parent directories to find `.tickets/` directory, enabling commands from any subdirectory diff --git a/ticket b/ticket index 2b14f64..3fe6dbc 100755 --- a/ticket +++ b/ticket @@ -55,6 +55,8 @@ init_tickets_dir() { return 1 } +TICKET_PAGER="${TICKET_PAGER:-${PAGER:-}}" + # Prefer ripgrep if available, fall back to grep if command -v rg &>/dev/null; then _grep() { rg "$@"; } @@ -1130,7 +1132,8 @@ cmd_show() { local target_id target_id=$(basename "$file" .md) - awk -v target="$target_id" -v target_file="$file" ' + _show_output() { + awk -v target="$target_id" -v target_file="$file" ' BEGIN { FS=": "; in_front=0 } # First pass: collect all ticket metadata @@ -1262,6 +1265,14 @@ cmd_show() { } } ' "$TICKETS_DIR"/*.md 2>/dev/null + } + + if [[ -t 1 && -n "$TICKET_PAGER" ]]; then + read -r -a pager_cmd <<<"$TICKET_PAGER" + _show_output | "${pager_cmd[@]}" + else + _show_output + fi } cmd_add_note() {