Permit to specify lines directly via $@. - plumb - Open certain URL patterns with an ad-hoc opener (plumber)
(HTM) hg clone https://bitbucket.org/iamleot/plumb
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) changeset f8e94a2a7bf561ea5a6ed7dde0ac2c48ecd3de42
(DIR) parent d951c65c07ef7e3c1a3fbdb189ce55fb71fbff84
(HTM) Author: Leonardo Taccari <iamleot@gmail.com>
Date: Mon, 26 Mar 2018 12:42:00
Permit to specify lines directly via $@.
If arguments are present just ignore the stdin and use $@ as lines that will be
piped in.
Introduce lines() function to permit that and adjust the main dplumb comment
accordingly.
Diffstat:
dplumb | 18 ++++++++++++++++--
1 files changed, 16 insertions(+), 2 deletions(-)
---
diff -r d951c65c07ef -r f8e94a2a7bf5 dplumb
--- a/dplumb Mon Mar 26 11:17:15 2018 +0200
+++ b/dplumb Mon Mar 26 12:42:00 2018 +0200
@@ -93,8 +93,9 @@
#
# dplumb, dmenu interface for plumb
#
-# Process the stdin, extract URLs, and list or pass them to ${PLUMB_DMENU}
-# and open the selected one to plumb.
+# Process options and for arguments passed via $@ or stdin if $@ is empty,
+# extract URLs, and list or pass them to ${PLUMB_DMENU} and open the selected
+# one to plumb.
#
main()
{
@@ -107,12 +108,25 @@
done
shift $((OPTIND - 1))
+ #
+ # If any arguments are present threat them as lines.
+ # Otherwise, just filter the stdin via cat.
+ #
+ args="$@"
+ if [ $# -gt 0 ]; then
+ lines() echo "${args}"
+ else
+ lines() cat
+ fi
+
if [ "$dplumb_list" = "yes" ]; then
+ lines |
one_word_per_line |
urlize |
extract_urls
else
plumb "$(
+ lines |
one_word_per_line |
urlize |
extract_urls |