skynet/yash/fzy-hist.sh

16 lines
336 B
Bash
Raw Normal View History

2025-03-19 11:36:08 -05:00
h() {
input="$*"
SED_ARG='s/^[[:digit:]]*[[:space:]]*//'
cmd="history | sed '\$d' | sort --reverse --numeric-sort | fzy "
2025-03-19 11:36:08 -05:00
if [ -n "$input" ]; then
cmd="$cmd -q\"\$input\" "
2025-03-19 11:36:08 -05:00
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"
2025-03-19 11:36:08 -05:00
}