blob: bfd2ee209d0e89f8afb3d3f3c039efe395cc8ef0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#!/bin/sh
# wa.sh
#
# Usage: wa.sh [STRING]...
#
# Passes argument strings or input to clipboard surrounded
# by Whatsapp's monospace macro lines.
#
# wa.sh without arguments uses 'cat -' to process input,
# so standard input is read if no input is provided.
if ! type xsel >/dev/null; then
echo "xsel not found: wa.sh depends on xsel." 1>&2
exit 1
fi
echo '```' | xsel -bi
if [ -n "$*" ]; then
echo "$@" | xsel -ba
else
cat - | xsel -ba
fi
echo '```' | xsel -ba
|