grep, preview, read, reply shlogs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.1 KiB

1 year ago
#!/bin/sh
# shlr - grep, preview, read, reply shlogs
1 year ago
# forked from /home/hannu/bin/shlr
# @hannu : thanks for fzf preview trick
# 2022.07.07 jul : added reply, fzf header, usage
1 year ago
LESS="-cK"
FZF_HEADER="Select with arrows, press ENTER for more, CTRL-R to reply or ESC to cancel."
if [ $# -gt 1 ] || [ "$1" = "-h" ]
then
echo "shlr - grep, preview, read, reply shlogs"
echo ""
echo "Usage: $0 [PATTERN]"
echo ""
echo "Reads with \$PAGER or 'less'."
echo "Reply with \$EDITOR."
exit 1
fi
1 year ago
if [ $1 ]
then
grep --directories=skip --files-with-matches --null "$@" /home/*/.shlog/* \
| xargs --null --no-run-if-empty stat -c "%y %n" \
| sort -r \
| cut -d ' ' -f4- \
| fzf \
--header="${FZF_HEADER}" \
1 year ago
--preview 'head -100 {}' \
--preview-window=down:75%:wrap \
--bind "enter:execute(${PAGER:-less} {}),ctrl-r:execute(/home/jul/prg/shlre/shlre {})" \
--exit-0
1 year ago
else
ls -t /home/*/.shlog/* | fzf \
--header="${FZF_HEADER}" \
1 year ago
--preview 'head -100 {}' \
--preview-window=down:75%:wrap \
--bind "enter:execute(${PAGER:-less} {}),ctrl-r:execute(/home/jul/prg/shlre/shlre {})"
1 year ago
fi