Skip to content

feat: ghistory/lhistory — session highlighting, time range and glob filtering - #124

Merged
oguyon merged 1 commit into
framework-devfrom
feat/ghistory-options
Mar 21, 2026
Merged

feat: ghistory/lhistory — session highlighting, time range and glob filtering#124
oguyon merged 1 commit into
framework-devfrom
feat/ghistory-options

Conversation

@oguyon

@oguyon oguyon commented Mar 21, 2026

Copy link
Copy Markdown
Member

Prompt Summary

User requested that ghistory command output highlight entries from the current session, and that both ghistory and lhistory gain new options for time range filtering and glob filtering on command names.

Changes

Enhances the ghistory and lhistory CLI commands with the following new capabilities:

New options

Option ghistory lhistory Description
N or -n N Show last N entries (ghistory default: 20; lhistory default: all)
-s SID Filter to a specific session ID
-g "PATTERN" Glob filter on command name (fnmatch, case-insensitive)
--since T Entries after timestamp T
--until T Entries before timestamp T
--today Entries from today only

Time format T: today, 15m, 2h, 3d, YYYY-MM-DD, YYYY-MM-DDTHH:MM:SS

Session highlighting

ghistory now displays current-session entries in bold green; other sessions are shown in normal colour.

Implementation notes

CLIcore_UI_history.c:

  • New HistDisplayOpts struct carries all filter/display options to history_log_display()
  • parse_time_arg() helper for flexible time parsing (relative and absolute formats)
  • cmdline_split() / cmdline_free() helpers parse data.CLIcmdline directly (single/double-quote aware), bypassing the calc parser which mangles dash-prefixed flags

CLIcore_UI.c:

  • When the first token is a CLI COMMAND and a subsequent token starts with -, it is now stored as CMDARGTOKEN_TYPE_RAWSTRING rather than being processed by the arithmetic expression parser. Without this, flags like -n, -g, --since set data.parseerror = 1, which silently prevents the command function from ever being called.

AI Authorship

  • Model used: Antigravity (Google DeepMind)
  • User edits: None — all changes authored by AI agent

Add filtering and highlighting to ghistory and lhistory:

- Current-session entries highlighted bold green in ghistory output
- -n N      : show last N entries (default 20 for ghistory, all for lhistory)
- -s SID    : filter by session ID (ghistory only)
- -g PATTERN: glob filter on command name (fnmatch, case-insensitive)
- --since T : entries after timestamp T
- --until T : entries before timestamp T
- --today   : entries from today midnight
  T formats: today, Nm, Nh, Nd, YYYY-MM-DD, YYYY-MM-DDTHH:MM:SS

Implementation details:
- HistDisplayOpts struct passed to history_log_display() for all filters
- cmdline_split() helper parses data.CLIcmdline directly (double/single
  quote aware) because the calc parser mangles dash-flag arguments
- CLIcore_UI.c: dash-prefixed args after a COMMAND token are stored as
  RAWSTRING (bypassing the arithmetic parser) to prevent parseerror=1
  from blocking the command function from being called
- cmdline_free() called after history_log_display() to avoid use-after-
  free on opts.glob_cmd and opts.filter_session pointers"
@oguyon
oguyon merged commit 0271647 into framework-dev Mar 21, 2026
1 of 2 checks passed
@oguyon
oguyon deleted the feat/ghistory-options branch March 21, 2026 23:32
oguyon added a commit that referenced this pull request May 21, 2026
…124)

Add filtering and highlighting to ghistory and lhistory:

- Current-session entries highlighted bold green in ghistory output
- -n N      : show last N entries (default 20 for ghistory, all for lhistory)
- -s SID    : filter by session ID (ghistory only)
- -g PATTERN: glob filter on command name (fnmatch, case-insensitive)
- --since T : entries after timestamp T
- --until T : entries before timestamp T
- --today   : entries from today midnight
  T formats: today, Nm, Nh, Nd, YYYY-MM-DD, YYYY-MM-DDTHH:MM:SS

Implementation details:
- HistDisplayOpts struct passed to history_log_display() for all filters
- cmdline_split() helper parses data.CLIcmdline directly (double/single
  quote aware) because the calc parser mangles dash-flag arguments
- CLIcore_UI.c: dash-prefixed args after a COMMAND token are stored as
  RAWSTRING (bypassing the arithmetic parser) to prevent parseerror=1
  from blocking the command function from being called
- cmdline_free() called after history_log_display() to avoid use-after-
  free on opts.glob_cmd and opts.filter_session pointers"
oguyon added a commit that referenced this pull request May 21, 2026
…124)

Add filtering and highlighting to ghistory and lhistory:

- Current-session entries highlighted bold green in ghistory output
- -n N      : show last N entries (default 20 for ghistory, all for lhistory)
- -s SID    : filter by session ID (ghistory only)
- -g PATTERN: glob filter on command name (fnmatch, case-insensitive)
- --since T : entries after timestamp T
- --until T : entries before timestamp T
- --today   : entries from today midnight
  T formats: today, Nm, Nh, Nd, YYYY-MM-DD, YYYY-MM-DDTHH:MM:SS

Implementation details:
- HistDisplayOpts struct passed to history_log_display() for all filters
- cmdline_split() helper parses data.CLIcmdline directly (double/single
  quote aware) because the calc parser mangles dash-flag arguments
- CLIcore_UI.c: dash-prefixed args after a COMMAND token are stored as
  RAWSTRING (bypassing the arithmetic parser) to prevent parseerror=1
  from blocking the command function from being called
- cmdline_free() called after history_log_display() to avoid use-after-
  free on opts.glob_cmd and opts.filter_session pointers"
oguyon added a commit that referenced this pull request May 22, 2026
…124)

Add filtering and highlighting to ghistory and lhistory:

- Current-session entries highlighted bold green in ghistory output
- -n N      : show last N entries (default 20 for ghistory, all for lhistory)
- -s SID    : filter by session ID (ghistory only)
- -g PATTERN: glob filter on command name (fnmatch, case-insensitive)
- --since T : entries after timestamp T
- --until T : entries before timestamp T
- --today   : entries from today midnight
  T formats: today, Nm, Nh, Nd, YYYY-MM-DD, YYYY-MM-DDTHH:MM:SS

Implementation details:
- HistDisplayOpts struct passed to history_log_display() for all filters
- cmdline_split() helper parses data.CLIcmdline directly (double/single
  quote aware) because the calc parser mangles dash-flag arguments
- CLIcore_UI.c: dash-prefixed args after a COMMAND token are stored as
  RAWSTRING (bypassing the arithmetic parser) to prevent parseerror=1
  from blocking the command function from being called
- cmdline_free() called after history_log_display() to avoid use-after-
  free on opts.glob_cmd and opts.filter_session pointers"
DasVinch pushed a commit that referenced this pull request May 29, 2026
…124)

Add filtering and highlighting to ghistory and lhistory:

- Current-session entries highlighted bold green in ghistory output
- -n N      : show last N entries (default 20 for ghistory, all for lhistory)
- -s SID    : filter by session ID (ghistory only)
- -g PATTERN: glob filter on command name (fnmatch, case-insensitive)
- --since T : entries after timestamp T
- --until T : entries before timestamp T
- --today   : entries from today midnight
  T formats: today, Nm, Nh, Nd, YYYY-MM-DD, YYYY-MM-DDTHH:MM:SS

Implementation details:
- HistDisplayOpts struct passed to history_log_display() for all filters
- cmdline_split() helper parses data.CLIcmdline directly (double/single
  quote aware) because the calc parser mangles dash-flag arguments
- CLIcore_UI.c: dash-prefixed args after a COMMAND token are stored as
  RAWSTRING (bypassing the arithmetic parser) to prevent parseerror=1
  from blocking the command function from being called
- cmdline_free() called after history_log_display() to avoid use-after-
  free on opts.glob_cmd and opts.filter_session pointers"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant