The i3 FAQ has migrated to All content here is read-only.
Ask Your Question

repeat or history for dmenu commands

asked 2015-07-15 12:29:26 +0000

biocyberman gravatar image

In shell you can use up/down arrows to access previously run commands. How can I have the similar behavior: $mod + D, then up/down arrows to select comamnd, and maybe edit before re-run the command

edit retag flag offensive close merge delete

3 answers

Sort by » oldest newest most voted

answered 2015-07-16 09:01:57 +0000

Adaephon gravatar image

The default for $mod+d currently is dmenu_run which utilizes dmenu for prompting.

In dmenu you can navigate the choises with either Left/Right for the (default) single-lined interface or Up/Down for the multi-line interface (with parameter -l NUMBER_OF_LINES). Tab pulls the selected choice and it can then be edited.

In order to have a history of recent commands you can modify dmenu_run to also save and display previous choices. I use the following script instead of dmenu_run (which I named emenu_run):

if [ -d "$cachedir" ]; then
    cache=$HOME/.emenu_cache # if no xdg dir, fall back to dotfile in ~
    hist=$HOME/.emenu_cache_hist # if no xdg dir, fall back to dotfile in ~
if [ ! -e "$hist" ]; then
    touch "$hist"
    echo foo
    if stest -dqr -n "$cache" $PATH; then
        (tac "$hist" ; stest -flx $PATH | sort -u | tee "$cache" ) | dmenu "$@"
        (tac "$hist"; cat "$cache") | dmenu "$@"

#echo "$cmd" | ${SHELL:-"/bin/sh"} &
i3-msg "exec $cmd"

sed -i -e "/^${cmd}$/d;${histsize}q" "$hist"
echo "$cmd" >> "$hist"

This saves the last 50 choices (edit histsize=50 for more or less) alongside the normal cache file and presents them first in order of recentness. It also uses i3-msg exec … instead of just passing it to a shell, which allows for applications that support it (unfortunatelly not all do) to appear on the workspace on which they were called.

edit flag offensive delete link more

answered 2015-07-15 13:36:54 +0000

biocyberman gravatar image

For future viewers, I found rofi: and I am very happy with it.

edit flag offensive delete link more

answered 2015-07-30 15:30:50 +0000

oberon gravatar image

Here's another script, not only assessing recency but also, if an app should be run in the background or in the terminal:

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2015-07-15 12:29:26 +0000

Seen: 328 times

Last updated: Jul 30