NAME
dwim
—
do what I mean with a given phrase
(file, URL etc.)
SYNOPSIS
dwim |
[-d ] [-o ]
[phrase] |
DESCRIPTION
dwim
is a program similar to Plan 9's
plumber. It takes a string (phrase) and matches it
against a number of regular expressions, which are connected to handlers,
specifying what to do with the phrase.
If no phrase is given, the current X
selection is retrieved from xsel(1). This is surprisingly useful. If you assign a shortcut key to
invoke dwim
in your window manager, you can select a
string of text, press the shortcut key and dwim
will
act on the selected text.
If the xtitle
program is installed on the
system, dwim
will try to figure out the current
working directory from the window title. The following title formats are
recognized:
Tilde expansion is supported.
EXAMPLES
Without X selection
Open Makefile in the configured text editor:
$ ls LICENSE Makefile README.md repl repl.1 repl.c $ dwim Makefile
With X selection
If we represent the current X selection with bold text, the following procedure opens message-window.lisp on line 164 in the configured text editor:
$ grep -n 'def.*indicator ' *.lisp
message-window.lisp:164:(defun show-frame-indicator (group &optional force)
$ dwim
CONFIGURATION
dwim
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:
- OPENER
xtopen
(change this toxterm -e
or equivalent)- EDITOR
OPENER vi
- PDF_VIEWER
xpdf
- MAN_VIEWER
OPENER man
- MAILER
OPENER mutt
- BROWSER
OPENER w3m -title
- FILE_BROWSER
OPENER noice
- MAILDIR_VIEWER
OPENER mutt -f
OPENER
is only used if the
-o
flag is specified.
AUTHORS
John Ankarström <john (at) ankarstrom.se>