1

I have a thought. Can I use a terminal as program runner?

Instead of dmenu / rofi I was thinking to list all the programs with FZF, run the selection, and then close the terminal after it runs.

I tried this but it's not working.

termite -e run.sh or urxvt -e zsh -c run.sh

run.sh consists of:

#!/bin/zsh
preexe() { kill -9 $PPID }
exec $(whence -pm '*' | fzf) &!
0

The exec ... &! starts exec ... in background and then exits.

You'd also want to decide where the command's stdin/stdout/stderr should go. You'd also want to detach the command from the terminal.

xterm -e zsh -c '
  set -o pipefail -o errexit
  print -rN -- $commands | fzf --read0 --print0 | IFS= read -rd "" cmd
  setsid -- "$cmd" <> /dev/null >&0 2>&0'

Here, we're running $cmd in a new session and with its I/O redirected from/to /dev/null. Ideally, you'd want to tell your window/session manager to start the command instead.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.