helm/weechat/bin/wee.sh
2017-01-03 03:44:35 -05:00

29 lines
504 B
Bash
Executable file

#!/usr/bin/env bash
# Pipes input to the weechat fifo (strips commented lines
# and prepends * to commands).
fifos=$(echo "$HOME/.weechat/weechat_fifo_*")
if [[ -z "$fifos" ]]; then
>&2 echo "No FIFOs. Is weechat running?"
exit 1
fi
rd() {
if [ -t 0 ]; then
cat $@
else
while read -r line; do
echo $line
done
fi | sed '/^ *\(#\|$\)/ d;s/^/*/g'
}
if [[ "$1" = "-d" ]]; then
shift
rd $@
else
rd $@ > $HOME/.weechat/weechat_fifo_*
fi