How do I pipe dmenu output into a command?
Solution 1:
The below script appears to bring up dmenu and return the selection to stdout in bash.
#!/bin/bash
cat ~/.bash_history | dmenu -l 20
exit
I got brought here as a top google search for the question header: "How do I pipe dmenu output into a command?". I was looking for a simple script to execute selections from dmenu in the bash shell. The following appears to work in bash:
#!/bin/bash
read thing2execute <<< $(cat ~/.bash_history | dmenu -l 20)
$thing2execute
exit
There is also a much more complex general purpose script to do this available on the suckless.org sit here: https://tools.suckless.org/dmenu/scripts/dmenu_run_with_command_history/