helm/weechat/bin/wee.sh

29 lines
504 B
Bash
Raw Normal View History

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