Mirrored from GitHub

Jump to: README.md ploomb.sh


README.md

1# ploomb <sub>(plumbing in Linux)</sub>
2
3this is a POSIX script for 'plumbing' text as search queries to websites
4
5## What is plumbing?
6
7Plumbing is a mechanism for passing messages between applications. It has a customizable set of rules (see `plumb(6)`) to process incoming messages and dispatch them to target applications.
8
9The `plumber(4)` is the file server that performs the message processing and dispatch.
10
11It is up to each application how it wishes to use this mechanism, but in the user-interface domain, the mechanism often allows the user to point to a file-name or URL and have the associated resource processed by an appropriate application.
12
13— [9p.io/wiki/plan9/using_plumbing/](https://9p.io/wiki/plan9/using_plumbing/)
14
15## Using ploomb
16
17- Bind to a key: [ploomb](//git.bauherren.ovh/ploomb)
18- Highlight a word/sentence in your graphical application
19- Run `ploomb`
20- Select an option from `dmenu`
21
22## Thanks
23
24- [Plumbing in Linux (a la Plan 9 from Bell Labs), by Luke Smith](//youtu.be/RlMxbQmMz_4?si=lQNjGDTkD1qvvUfw)  
25  - Author of *cabl*, a BASH script to bring the concept of plumbing to Linux. Discusses using *cabl* without a mouse.
26
27- [Plumbing for language learners](//tatsumoto-ren.github.io/blog/plumbing-for-language-learners.html)  
28  - Adds replete and more complex functions to Luke's *cabl* script, tailored to language learning.
29
30## Author
31
32Forward complaints to [christos@bauherren.ovh](mailto:christos@bauherren.ovh)
33

ploomb.sh

1#!/bin/sh
2
3search_text="$( { xclip -o || xclip -o -selection clipboard; } | tr '[:upper:]' '[:lower:]')"
4
5readonly search_text
6
7search() {
8    "$BROWSER" "https://google.com/search?q=$*"
9}
10
11wiki() {
12	"$BROWSER" "https://en.wikipedia.org/wiki/$*"
13}
14
15mal() {
16	"$BROWSER" "https://myanimelist.net/search/all?q=$*"
17}
18
19yab() {
20	"$BROWSER" "https://chinese.yabla.com/chinese-english-pinyin-dictionary.php?define=$*"
21}
22
23yb() {
24	"$BROWSER" "https://yellowbridge.com/chinese/sentsearch.php?word=$*"
25}
26
27web() {
28    "$BROWSER" "$@"
29}
30
31ety() {
32    "$BROWSER" "https://en.wiktionary.org/wiki/$*"
33}
34
35yt() {
36	"$BROWSER" "https://www.youtube.com/results?search_query=$*"
37}
38
39__ask_action() {
40    declare -F | awk '!/ __.+$/ {gsub("_", " ", $3); print $3}' |
41        dmenu -p "Send ${search_text:0:30} to?" -i -l 50
42}
43
44__main() {
45    if [ -n "${func:=$(__ask_action)}" ]; then
46        "${func// /_}" "$search_text"
47    fi
48}
49
50__main