skynet/yash/fzy-hist.sh

15 lines
336 B
Bash

h() {
input="$*"
SED_ARG='s/^[[:digit:]]*[[:space:]]*//'
cmd="history | sed '\$d' | sort --reverse --numeric-sort | fzy "
if [ -n "$input" ]; then
cmd="$cmd -q\"\$input\" "
fi
cmd="$cmd | sed \"\$SED_ARG\" | tr -d '\n'"
if command -v wl-copy>/dev/null; then
cmd="$cmd | wl-copy 2>/dev/null"
fi
eval "$cmd"
}