skynet/yash/fzy-hist.sh

9 lines
339 B
Bash

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
}