aboutsummaryrefslogtreecommitdiff
path: root/xplumb
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-11-06 17:01:53 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2024-11-06 17:01:53 +0100
commit778574d025cf7a23b386d8cb110e265dd334dfc2 (patch)
treec6ec796d8afbb0a0f3eb1baafed6c01a0a8126de /xplumb
parent31a433b6a68cf924b70039abc6464453c323acf2 (diff)
downloadscripts-778574d025cf7a23b386d8cb110e265dd334dfc2.tar.gz
scripts-778574d025cf7a23b386d8cb110e265dd334dfc2.zip
Moved unused stuff
Diffstat (limited to 'xplumb')
-rwxr-xr-xxplumb65
1 files changed, 0 insertions, 65 deletions
diff --git a/xplumb b/xplumb
deleted file mode 100755
index 1d89796..0000000
--- a/xplumb
+++ /dev/null
@@ -1,65 +0,0 @@
1#!/bin/sh
2
3# My interpretation of a plumber (plan9 style).
4# It scans the selected text (xsel) and decides what to do with it among
5# some possibilities (open file, open url, man page...). If none is matched,
6# a choice is prompted.
7
8# Requires: dmenu (or similar), mail-compose, open-file, terminal, websearch,
9# xedit, xsel
10
11# TODO:
12# send mail to email address;
13# calendar if it is a date
14# choice: pipe to another program
15
16browser=${BROWSER:-firefox}
17menu=${MENU:-dmenu}
18menuopts="-l 10"
19
20text=$(xsel | sed 's/\n/ /g')
21if [ "${#text}" -ge 11 ]; then
22 shorttext=$(echo "$text" | cut -b 1-10)...
23else
24 shorttext="$text"
25fi
26
27choice() {
28 chosen=$(printf "websearch\nedit" | \
29 $menu $menuopts -p "What to do with \"$shorttext\"?")
30
31 if [ "$chosen" = "websearch" ]; then
32 websearch "$text"
33 elif [ "$chosen" = "edit" ]; then
34 f=$(mktemp)
35 xsel > "$f"
36 xedit "$f"
37 fi
38}
39
40trymail() {
41 addr=$(echo "$1" | addressgrep)
42 ( [ -n "$addr" ] && mail-compose "$addr" ) || return 1
43}
44
45tryman() {
46 number=$(echo "$1" | sed 's/[^1-8]//g')
47 name=$(echo "$1" | sed 's/([1-8])//g' | sed 's/ //g')
48 if [ "$(man -w "$number" "$name" | wc -l)" = 1 ]; then
49 terminal -e man "$number" "$name"
50 return 0
51 else
52 return 1
53 fi
54}
55
56tryurl() {
57 url=$(echo "$1" | urlgrep)
58 ( [ -n "$url" ] && "$browser" "$url" ) || return 1
59}
60
61#open-file -s spawn "$text" || \
62tryurl "$text" || \
63trymail "$text" || \
64tryman "$text" || \
65choice

Generated with cgit - Back to sebastiano.tronto.net