2

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) &!
celadon
  • 117
  • 9
Nora
  • 21
  • 1

1 Answers1

1

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.

Stéphane Chazelas
  • 522,931
  • 91
  • 1,010
  • 1,501