aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorInigoGutierrez <inigogf.95@gmail.com>2019-11-06 22:40:48 +0100
committerInigoGutierrez <inigogf.95@gmail.com>2019-11-06 22:40:48 +0100
commit8f247ce3b9cde5021e7d7d3ace8b0a486c6d1390 (patch)
treefed4e660b73df9a07f4ec095c2c4b64c208f0c10
parent9315b5aa24f8b2dd73624932ab36bf159bf7760e (diff)
downloadscripts-8f247ce3b9cde5021e7d7d3ace8b0a486c6d1390.tar.gz
scripts-8f247ce3b9cde5021e7d7d3ace8b0a486c6d1390.zip
wa.sh now accepts arguments as input.
-rwxr-xr-xwa.sh18
1 files changed, 11 insertions, 7 deletions
diff --git a/wa.sh b/wa.sh
index 39ac46f..bfd2ee2 100755
--- a/wa.sh
+++ b/wa.sh
@@ -2,13 +2,13 @@
# wa.sh
#
-# Usage: wa.sh
+# Usage: wa.sh [STRING]...
#
-# Passes input to clipboard surrounded by Whatsapp's
-# monospace macro lines.
+# Passes argument strings or input to clipboard surrounded
+# by Whatsapp's monospace macro lines.
#
-# wa.sh uses 'cat -' to process input, so standard
-# input is read if no input is provided.
+# 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
@@ -16,5 +16,9 @@ if ! type xsel >/dev/null; then
fi
echo '```' | xsel -bi
-cat - | xsel -ba
-echo -n '```' | xsel -ba
+if [ -n "$*" ]; then
+ echo "$@" | xsel -ba
+else
+ cat - | xsel -ba
+fi
+echo '```' | xsel -ba