From 5fd15e5b07df509940030aa02475d9b4453e47bd Mon Sep 17 00:00:00 2001 From: Rudis Muiznieks <rudis@sitosis.com> Date: Wed, 19 Mar 2025 11:36:08 -0500 Subject: [PATCH] added fzy history shortcut --- yash/_yashrc | 6 ++++-- yash/fzy-hist.sh | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 yash/fzy-hist.sh diff --git a/yash/_yashrc b/yash/_yashrc index 123f2d5..a03495d 100644 --- a/yash/_yashrc +++ b/yash/_yashrc @@ -8,14 +8,16 @@ set --notify-le set --le-no-conv-meta set --le-predict ! [ -d ~/.cache/yash ] && mkdir -p ~/.cache/yash +HISTRMDUP=50 HISTFILE=~/.cache/yash/history -HISTSIZE=100000 +HISTSIZE=50000 PS1P="\fi" FCEDIT=hx -# prompt and z +# yash extension scripts . ~/skynet/yash/polyglot.sh . ~/skynet/yash/z.sh +. ~/skynet/yash/fzy-hist.sh # environment setup export PURE_GIT_PULL=0 diff --git a/yash/fzy-hist.sh b/yash/fzy-hist.sh new file mode 100644 index 0000000..c5debe0 --- /dev/null +++ b/yash/fzy-hist.sh @@ -0,0 +1,9 @@ +h() { + input="$*" + SED_ARG='s/^[[:digit:]]*[[:space:]]*//' + if [ -n "$input" ]; then + history | sed '$d' | sort --reverse --numeric-sort | fzy -q"$input" | sed "$SED_ARG" | tr -d '\n' | wl-copy 2>/dev/null + else + history | sed '$d' | sort --reverse --numeric-sort | fzy | sed "$SED_ARG" | tr -d '\n' | wl-copy 2>/dev/null + fi +}