Skip to content

Instantly share code, notes, and snippets.

@marendowski
Last active October 21, 2023 19:45
Show Gist options
  • Save marendowski/03d1a24235e83923b428b8ee962d2a88 to your computer and use it in GitHub Desktop.
Save marendowski/03d1a24235e83923b428b8ee962d2a88 to your computer and use it in GitHub Desktop.
Run commands using dmenu in st terminal
#!/bin/sh
# run commands in dmenu by adding ! at the end
# otherwise runs selected program
cmd="$(dmenu_path | dmenu -p "Run >" $@)"
case $cmd in
*\! ) cmd=$(printf "%s" "${cmd}" | cut -d'!' -f1);
st -e sh -c "${cmd};exec $SHELL";;
* ) ${cmd} ;;
esac
# it first cuts the `!` and then
# runs st with sh with this command and then runs
# shell to enter shell and have command's output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment