aboutsummaryrefslogtreecommitdiff
path: root/dwim.1
blob: d2e95fa0ecde6645a286d6b262d88c41e47d31b0 (plain)
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
.Dd $Mdocdate$
.Dt DWIM 1
.Os
.Sh NAME
.Nm dwim
.Nd do what I mean with a given phrase (file, URL etc.)
.
.Sh SYNOPSIS
.Nm dwim
.Op Fl d
.Op Ar phrase
.
.Sh DESCRIPTION
.Pp
.Nm dwim
is a program similar to Plan 9's plumber.
It takes a string
.Ar ( phrase )
and matches it against a number of regular expressions,
which are connected to handlers, specifying what to do with the phrase.
.Pp
If no
.Ar phrase
is given, the current X selection is retrieved from
.Xr xsel 1 .
This is surprisingly useful.
If you assign a shortcut key to invoke
.Nm dwim
in your window manager,
you can select a string of text,
press the shortcut key and
.Nm
will act on the selected text.
.Pp
If the
.Li xtitle
program is installed on the system,
.Nm
will try to figure out the current working directory
from the window title.
The following title formats are recognized:
.Bl -enum -offset indent -compact
.It
.Em path
.It
.Em program
.Em ( path )
.El
.Pp
Tilde expansion is supported.
.Sh EXAMPLES
.Ss Without X selection
Open
.Em Makefile
in the configured text editor:
.Bd -literal
$ ls
LICENSE   Makefile  README.md repl      repl.1    repl.c
$ dwim Makefile
.Ed
.Ss With X selection
.Pp
If we represent the current X selection with bold text,
the following procedure opens
.Em message-window.lisp
on line 164
in the configured text editor:
.Bd -literal
$ grep -n 'def.*indicator ' *.lisp 
\f(CBmessage-window.lisp:164:(defun\fP show-frame-indicator (group &optional force)
$ dwim
.Ed
.Sh CONFIGURATION
.Nm
is configured by editing the source code.
It is a simple Perl script,
which uses regular expressions to parse phrases.
Default programs are defined at the top of the script.
The following associations are defined by default:
.Bl -tag -width 18n -offset indent -compact
.It OPENER
.Li xtopen
(change this to
.Li xterm -e
or equivalent)
.It EDITOR
.Li OPENER vi
.It PDF_VIEWER
.Li xpdf
.It MAN_VIEWER
.Li OPENER man
.It MAILER
.Li OPENER mutt
.It BROWSER
.Li OPENER w3m -title
.It FILE_BROWSER
.Li OPENER noice
.It MAILDIR_VIEWER
.Li OPENER mutt -f
.El
.Sh AUTHORS
.An -nosplit
.An John Ankarström Aq Mt "john (at) ankarstrom.se"