helm/misc/weechat/bin/wee
2017-12-06 01:39:10 -05:00

23 lines
487 B
Bash
Executable file

#!/usr/bin/env bash
# Pipes input to the weechat fifo (strips commented lines
# and prepends * to commands).
fifos=$(echo ~/.weechat/weechat_fifo_*)
if ! pgrep -x weechat >/dev/null; then
>&2 echo "Weechat isn't running"
exit 1
elif [[ ! -e ~/.weechat/weechat_fifo ]]; then
>&2 echo "No weechat fifo files available"
exit 2
fi
if [[ -t 0 ]]; then
while read -r line; do
echo $line
done
else
cat $@
fi | sed '/^ *\(#\|$\)/ d;s/^[ \t]*/*/g' >~/.weechat/weechat_fifo*