[xmonad] XMonad.Prompt.File (attached)

John J Foerch jjfoerch at earthlink.net
Fri Mar 18 04:45:37 CET 2011


Gwern Branwen <gwern0 at gmail.com> writes:
> On Wed, Mar 16, 2011 at 10:45 PM, John J Foerch <jjfoerch at earthlink.net> wrote:
>> I had need in my config for a filename prompt.  XMonad-Contrib contains
>> XMonad.Prompt.Directory, so I just copied it and made the appropriate
>> substitutions to make XMonad.Prompt.File.  It would be great if this
>> could be added to xmonad-contrib so it will be there for the next person
>> who needs this functionality.
>
> Well, as you say, it's basically just a copy-paste with one small change:
>
> 36,38c36,38
> < getFileCompl :: String -> IO [String]
> < getFileCompl s = (filter notboring . lines) `fmap`
> <                  runProcessWithInput "/bin/bash" [] ("compgen -A
> file " ++ s ++ "\n")
> ---
>> getDirCompl :: String -> IO [String]
>> getDirCompl s = (filter notboring . lines) `fmap`
>>                 runProcessWithInput "/bin/bash" [] ("compgen -A directory " ++ s ++ "\n")
>
> As it stands, I would be adamantly  against inclusion; such copy-paste
> is not the Haskell way. Surely there is a better approach? I can't
> help but suspect that this functionality may already be supplied by
> another module (perhaps the Shell prompt meets your needs).
>

Sorry it couldn't be a more profound, creative, and interesting module :D
but that's what I needed.  Shell prompt does not fit the bill for two
reasons: 1) its prompt string is hard-coded as "Run: ", and 2) I wanted
expansion of '~/' but not other special characters, so I have to
manipulate the return value before passing it on to spawn.

For context, I'm using this in several screenshot commands which prompt
for the name of the output file.

Maybe there is a better approach for prompting for directories and files
both, but the existence of an XMonad.Prompt.Directory and no
XMonad.Prompt.File looks to me like a simple omission.  If the latter is a
hack, then so is the former, but I'm not campaigning for any outcome, only
offering something that I have found useful to others.

Have a nice day!

-- 
John Foerch




More information about the xmonad mailing list