From 91adc03b90dd3076e873eee19987b38b2bcef730 Mon Sep 17 00:00:00 2001 From: thek4n Date: Thu, 12 Mar 2026 18:48:19 +0300 Subject: [PATCH] fix zsh history --- home/user/.config/zsh/history | 4 +++- home/user/.config/zsh/mappings | 34 ++++++++++++++++++++-------------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/home/user/.config/zsh/history b/home/user/.config/zsh/history index 69d6dcc..c9997ea 100644 --- a/home/user/.config/zsh/history +++ b/home/user/.config/zsh/history @@ -11,6 +11,8 @@ setopt HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a dupl setopt HIST_IGNORE_SPACE # Don't record an entry starting with a space. setopt HIST_FIND_NO_DUPS # Do not display a line previously found. setopt HIST_SAVE_NO_DUPS # Don't write duplicate entries in the history file. +setopt HIST_REDUCE_BLANKS # Убирать лишние пробелы из командных строк, добавляемых в историю. +setopt HIST_NO_STORE # Не хранить записи о командах history. export HISTSIZE=100000 @@ -29,4 +31,4 @@ zshaddhistory() { ## should use EXTENDED_GLOB syntax setopt extendedglob [[ ${1::-1} != ${~HISTORY_IGNORE} ]] -} \ No newline at end of file +} diff --git a/home/user/.config/zsh/mappings b/home/user/.config/zsh/mappings index b0743e8..4373378 100644 --- a/home/user/.config/zsh/mappings +++ b/home/user/.config/zsh/mappings @@ -89,22 +89,28 @@ zle -N cddotdot bindkey "^O" cddotdot bindkey -M vicmd "^O" cddotdot - - fzfhistory() { local cmd - cmd=$(fc -l 1 | \ - sed 's/^[ ]*[0-9]*[ ]*//' | \ - fzf \ - --ignore-case \ - --scheme=history \ - --no-multi \ - --tac \ - --tiebreak=begin,index \ - --height="$((${LINES}/4))" \ - --query="${BUFFER}" \ - --preview="echo {} | sed 's/\\\n/\\n/g' | highlight -O ansi -S zsh" \ - --preview-window=wrap:30%:50% | sed 's/\\n/\n/g') +cmd=$(fc -il 1 | \ + awk '{ + original = $0; + clean = $0; + sub(/^[ ]*[0-9]+[ ]+[0-9]{4}-[0-9]{2}-[0-9]{2}[ ]+[0-9]{2}:[0-9]{2}[ ]*/, "", clean); + print clean "\t" original + }' | \ + fzf \ + --ignore-case \ + --scheme=history \ + --no-multi \ + --tac \ + --tiebreak=begin,index \ + --height="$((${LINES}/4))" \ + --query="${BUFFER}" \ + --delimiter=$'\t' \ + --with-nth=1 \ + --preview="echo {2} | sed 's/\\\n/\\n/g' | highlight -O ansi -S zsh" \ + --preview-window=wrap:30%:50% | \ + cut -f1 | sed 's/\\n/\n/g') if [[ -n "${cmd}" ]]; then BUFFER="${cmd}"