Created
February 14, 2022 23:23
-
-
Save rkitover/72a9ce81c63be5f1ce9c775ea0b485b0 to your computer and use it in GitHub Desktop.
weechat log viewer sh function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irclog() { | |
chan_log=$(find ~/.weechat/logs -name "*.#${1}.*" -printf '%p ' | sed 's/ $//') | |
case "$chan_log" in | |
*" "*) | |
echo >&2 'irclog: multiple matches' | |
unset chan_log | |
return 1 | |
;; | |
"") | |
echo >&2 'irclog: no matches' | |
unset chan_log | |
return 1 | |
;; | |
esac | |
e=$(printf '\033') | |
sed -En "s/^[0-9]{4}-(.{11}).*:[0-9][0-9][[:space:]]+([^-<[:space:]][^[:space:]]+)[[:space:]]+(.*)/${e}[1;97m\\1${e}[0m ${e}[1;97m<${e}[0;38;2;140;206;250m\\2${e}[1;97m>${e}[0m \\3/p" "$chan_log" | less -r | |
unset chan_log e | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment