Last active
July 31, 2024 00:31
-
-
Save y16ra/ecaedad1cccc12e4df23ee361c5a3203 to your computer and use it in GitHub Desktop.
Interactive History Search
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HIST_STAMPS="yyyy-mm-dd" | |
# fzf history | |
function fzf-select-history() { | |
local selected=$(history -n -r 1 | fzf --query "$LBUFFER" --reverse) | |
if [ -n "$selected" ]; then | |
BUFFER=$(echo "$selected" | awk '{$1=""; $2=""; print $0}' | sed 's/^[ \t]*//') | |
CURSOR=$#BUFFER | |
zle reset-prompt | |
fi | |
} | |
zle -N fzf-select-history | |
bindkey '^r' fzf-select-history |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Each history entry shows the date, time, and the full command.
Format example:
2023-07-31 09:25 vi .zshrc