mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2025-12-22 15:52:31 +01:00
Add match_prev_cmd strategy.
A new suggestion strategy 'match_prev_cmd' is available. This is a bit more context aware variaton on the default strategy. The suggestion will be: - The newest history entry that matches the current prefix, AND - Whose preceding history entry also matches the previously executed command. See src/strategies/match_prev_cmd.zsh for an example.
This commit is contained in:
parent
976acc708c
commit
73f774bd5d
4 changed files with 232 additions and 0 deletions
|
|
@ -19,3 +19,8 @@ _zsh_autosuggest_escape_command_prefix() {
|
|||
# Escape special chars in the string (requires EXTENDED_GLOB)
|
||||
echo -E "${1//(#m)[\\()\[\]|*?]/\\$MATCH}"
|
||||
}
|
||||
|
||||
# Get the previously executed command (hookable for testing)
|
||||
_zsh_autosuggest_prev_command() {
|
||||
echo -E "${history[$((HISTCMD-1))]}"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue