Re: [hackers] [dmenu][RFC][PATCH 0/4] Using sort and simple C program to get dmenu history functionality

From: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Mon, 30 Nov 2015 18:51:02 +0100

On Mon, Nov 30, 2015 at 3:28 PM, Silvan Jegen <s.jegen_AT_gmail.com> wrote:
> Heyho!
>
> On Sat, Nov 28, 2015 at 11:25 PM, Hiltjo Posthuma
> <hiltjo_AT_codemadness.org> wrote:
>> On Fri, Nov 27, 2015 at 7:38 PM, Silvan Jegen <s.jegen_AT_gmail.com> wrote:
>> This can be implemented in a few lines of shell (wc, sort) and maybe awk.
>
> I *have* implemented the history part with sort. If you think the
> history updating functionality that I ended up writing in C can be
> (easily?) implemented in some shell script and/or awk then I would
> like to see it on the list :)
>

Something like (quick hack):

cat historyfile | awk '//{x[$0]++; } END { for (k in x) { print x[k] "
   " k; }}' | sort -k 1rn,2 | cut -f 2- | dmenu >> historyfile

> I thought it should be possible to implement in awk but because you
> have to both read input from stdin (the command) and from a file (the
> history file) I couldn't figure it out in the admittedly short time I
> kept trying to do it.
>

The input is read from X, not stdin, but if you mean additional input
apart from the history file you can append it and probably use some
kind of "weights" (like used count), then after it use sort like
above.

Kind regards,
Hiltjo
Received on Mon Nov 30 2015 - 18:51:02 CET

This archive was generated by hypermail 2.3.0 : Mon Nov 30 2015 - 19:00:17 CET