From 8f247ce3b9cde5021e7d7d3ace8b0a486c6d1390 Mon Sep 17 00:00:00 2001 From: InigoGutierrez Date: Wed, 6 Nov 2019 22:40:48 +0100 Subject: wa.sh now accepts arguments as input. --- wa.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'wa.sh') 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 -- cgit v1.2.1