feat(history): support N-th history index in substitution #2

Merged
rootiest merged 1 commits from feat/hist-sub into main 2026-04-30 22:27:30 +00:00
Owner

This PR enhances the interactive history substitution function (Ctrl+F) to support an optional history index.

Changes:

  • N-th History Support: You can now use the syntax old/new/index (e.g., foo/bar/3) to perform substitution on the 3rd most recent command in history.
  • Improved Robustness: Added checks to ensure the target command exists before attempting replacement.
  • Sudo Fallback: Maintained existing behavior where an empty command line prepends sudo to the last command.

Verified with local testing.

This PR enhances the interactive history substitution function (`Ctrl+F`) to support an optional history index. ### Changes: - **N-th History Support:** You can now use the syntax `old/new/index` (e.g., `foo/bar/3`) to perform substitution on the 3rd most recent command in history. - **Improved Robustness:** Added checks to ensure the target command exists before attempting replacement. - **Sudo Fallback:** Maintained existing behavior where an empty command line prepends `sudo` to the last command. Verified with local testing.
rootiest added 1 commit 2026-04-30 22:25:04 +00:00
Extends the interactive history substitution function to support an
optional third field `old/new/index`.

- Keeps default behavior of targeting the most recent command (index 1).
- Allows targeting a specific history entry by appending a number.
- Validates that the index is a positive integer before attempting retrieval.
- Safely handles cases where the requested history index does not exist.

Example: 'cat/bat/5' now replaces 'cat' with 'bat' in the 5th previous command.
rootiest merged commit 6397e10f2e into main 2026-04-30 22:27:30 +00:00
rootiest deleted branch feat/hist-sub 2026-04-30 22:27:31 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: rootiest/fish-config#2