.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"