1 # Prompt for a programs to run
4 CACHE="${XDG_CACHE_HOME:-$HOME/.cache}"
9 printf 'Usage: %s [cmd [args...] [+]]
11 cmd do not prompt for a command and run cmd right away
12 args do not prompt for arguments neither and use arg
13 + if present after the arguments, prompt for a path\n' "${0##*/}"
18 # Update the cache and get the command to run.
26 [ "$CACHE/dmenu_run" -ot "$dir" ] && u=1
29 [ "$u" -eq 1 ] && find -L $PATH -type f -exec test -x {} \; -print |
30 sed 's|.*/||' | sort -u > "$CACHE/dmenu_run"
35 # Prompt for options for a given command and log it to an history file
41 printf '%s ' "$command" >> "$CACHE/iomenu/run"
45 [ "$command" = "$cmd" ] && printf '%s\n' "$opt"
46 done < "$CACHE/iomenu/run" |
47 iomenu -p "$command" | tee -a "$CACHE/iomenu/run"
49 sort -u "$CACHE/iomenu/run" -o "$CACHE/iomenu/run"
54 # Prompt for a file path in $HOME and print it.
58 find "$HOME" ! -path "$CACHE" ! -path '*/.git/*' |
59 sed -r "s/.{${#HOME}}/~/" | iomenu -l 256 | sed 's/^~//'
64 # Get the options according to the command and run it
68 command="${1:-$(iomenu -l 256 -s '#' < "$CACHE/dmenu_run")}"
70 [ -z "$command" ] && exit 1
72 options="$(get_options "$command")"
74 if [ "$options" ] && [ -z "${options%%*+}" ]
76 path="$(get_path)" options="${options%+}"
80 then exec $command $options "$path"
81 else exec $command $options
88 mkdir -p "$CACHE/iomenu"
90 if [ $# -gt 0 ] && [ -z "${1##-*}" ]