[xmonad] Search in prompt history?

Gwern Branwen gwern0 at gmail.com
Sat Nov 14 18:26:52 EST 2009


On Sat, Nov 14, 2009 at 4:27 AM, Frank Bauer <frank.c.bauer at gmail.com> wrote:
> Hi all,
>
> I'm new xmonad user (been using it for 2 months) and one feature
> I am missing is searching in the prompt history.
>
> I use various prompts like Man, Ssh, Shell and Window and in addition
> to going through the history line by line I would like to be able to type
> a few characters, press some key (e.g. Ctrl+Up) and the prompt would
> seek to the first such occurence in the prompt history.
> For those of you who know ion, that is it[*]
>
> Is it possible in xmonad? As I am not a programmer, I just craft my
> xmonad.hs by copying parts of setup I find on the internet without really
> understanding them - either they work or they don't.
> So far I did not find anything resembling this functionality.
>
> Regards,
> [*] I used ion window manager since the first version (2002?) for
> many years until Tuomo changed the licence and it dropped out
> of Debian. I briefly tried Awesome, which was lacking some of the
> features (e.g. scratchpad) and that lead me to xmonad because its
> defaults suit me better.

If you try out Actions.Search, you'll notice that tab-completion is
done on only prior search queries and not files or hosts or the others
you've tried. If you look at Prompt.hs you'll see some completion
functions like:

 -- | 'historyCompletion' provides a canned completion function much like
 --   'getShellCompl'; you pass it to mkXPrompt, and it will make
completions work
 --   from the query history stored in ~\/.xmonad\/history.
 historyCompletion :: ComplFunction
 historyCompletion = historyCompletionP (const True)

If you wanted to make some uber completion, you could combine
completion functions. That is, the guts tend to look something like
this:

 getShellCompl :: [String] -> String -> IO [String]

If we have [String] for shell-only completions, and we have [String]
for just history completions, we could combine the 2 lists with ++ or
write an interleave function like

 interleave [] y = y
 interleave x [] = x
 interleave (x:xs) (y:ys) = x : y : interleave xs ys

You could also rewrite the promptKeyMap field in an XPConfig to change
the default binding:

  , (xK_Up, moveHistory W.focusDown')

Or you could reset the completionKey field to Up instead of Tab.

-- 
gwern


More information about the xmonad mailing list