repeat or history for dmenu commands
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
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
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.
For future viewers, I found rofi: https://github.com/DaveDavenport/rofi and I am very happy with it.
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...
Asked: 2015-07-15 12:29:26 +0000
Seen: 328 times
Last updated: Jul 30