The i3 FAQ has migrated to https://www.reddit.com/r/i3wm/. All content here is read-only.
Ask Your Question
1

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
1

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):

#!/bin/sh
cachedir=${XDG_CACHE_HOME:-"$HOME/.cache"}
histsize=50
if [ -d "$cachedir" ]; then
    cache=$cachedir/emenu
    hist=$cachedir/emenu_hist
else
    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 ~
fi
if [ ! -e "$hist" ]; then
    touch "$hist"
    echo foo
fi
cmd=$(
    IFS=:
    if stest -dqr -n "$cache" $PATH; then
        (tac "$hist" ; stest -flx $PATH | sort -u | tee "$cache" ) | dmenu "$@"
    else
        (tac "$hist"; cat "$cache") | dmenu "$@"
    fi
    ) 

#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
1

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

biocyberman gravatar image

For future viewers, I found rofi: https://github.com/DaveDavenport/rofi and I am very happy with it.

edit flag offensive delete link more
0

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: https://github.com/manjaro/packages-c...

edit flag offensive delete link more

Question Tools

1 follower

Stats

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

Seen: 328 times

Last updated: Jul 30