1

I wanted to use a window-manager key binding to open fzf in xterm and then open the chosen file. So I bound a key to spawn xterm -e fzf-open, and put this in fzf-open:

    #!/usr/bin/bash

    # fzf-open: find a file and open it

    if file=$(find ~ -type f -name "*.pdf" |
                    fzf); then
            xdg-open "$file" &
            # disown
    fi

But this only works when run from the terminal. The key binding doesn't work, unless I remove the & and let the dedicated xterm window hang while the opened file is open.

I take it this means that, when xterm dies, it takes its children with it. The appropriate programme is run, but killed when xterm dies. I tried to put disown after the xdg-open ... line, but that didn't make any difference.

How can I prevent xterm from taking the programme with it when it dies?

Toothrot
  • 3,435
  • 2
    Try this: (trap '' HUP; xdg-open "$file" >/dev/null 2>&1 &). See this for an explanation. –  Mar 04 '20 at 22:41

0 Answers0