-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.plumb
145 lines (120 loc) · 2.56 KB
/
.plumb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# default plumbing rules
#
# rules are tried in the order given, return 0 if the rule should be
# skipped.
#
# Now, customize!
set browser firefox
set image_viewer sxiv
set pdf_viewer mupdf
set media_player mpv
# ZIP archives
Plumb {^.*\.zip$} {
if {[file exists [GetArg 0]]} {
RunOutput unzip -l [GetArg 0]
return 1
}
return 0
}
# TAR archives
Plumb {^.*\.tar\..*$} {
if {[file exists [GetArg 0]]} {
RunOutput tar tf [GetArg 0]
return 1
}
return 0
}
# CHICKEN tickets
Plumb {^#([[:digit:]]+)} {
exec plumb "https://bugs.call-cc.org/ticket/[GetArg 1]"
return 1
}
# Emails
Plumb {^<mail:(.+)>$} {
Run Mail [GetArg 1]
return 1
}
# scheme documentation "(path to manual page)"
Plumb {^\((.+)\)$} {
set page [split [GetArg 1]]
RunOutput chicken-doc $page
return 1
}
# image files
Plumb {^(.+)(.png|.jpg|.jpeg|.gif)$} {
set fname [GetArg 0]
if {[file exists $fname]} {
global image_viewer
Run $image_viewer $fname
return 1
}
return 0
}
# PDF files
Plumb {^(.+).pdf$} {
set fname [GetArg 0]
if {[file exists $fname]} {
global pdf_viewer
Run $pdf_viewer $fname
return 1
}
return 0
}
# Youtube URLs
Plumb {^https://www.youtube\.com/.*$} {
global media_player
Run $media_player [GetArg 0]
return 1
}
# <URL>
Plumb {^(http|https|ftp)://[-A-Za-z0-9_.+%/&?=#~:]+$} {
global browser
Run $browser [GetArg 0]
return 1
}
# "..." / "<...>" (include file)
set include_path {"/usr/include"}
if {[info exists env(C_INCLUDE_PATH)]} {
set include_path [concat $include_path [split $env(C_INCLUDE_PATH) ":"]]
}
proc FindInPath {fname path} {
set found {}
foreach x $path {
set fn [file join $x $fname]
if {[file exists $fn]} {
lappend found $fn
}
}
return $found
}
proc GotoIncludeFile {fname} {
global include_path
set found [FindInPath $fname $include_path]
if {$found != ""} {
Run B [lindex $found 0]
return 1
}
return 0
}
Plumb {^"([^"]+)"$} {return [GotoIncludeFile [GetArg]]}
Plumb {^<([^>]+)>$} {return [GotoIncludeFile [GetArg]]}
# <manpage>(<n>)
Plumb {^(\S+)\((\d+)\)$} {
RunOutput man [GetArg 2] [GetArg 1]
return 1
}
# <file>:[<addr>]
Plumb {^(.*):([^:]*)$} {
set fname [GetArg 0]
if {[file exists $fname]} {
Run B $fname
return 1
}
set fname [GetArg 1]
set address [GetArg 2]
if {[file exists $fname]} {
Run B "$fname:$address"
return 1
}
return 0
}