Skip to content

Instantly share code, notes, and snippets.

@illustris illustris/emenu
Created Dec 16, 2019

Embed
What would you like to do?
dmenu + history
#!/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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.