How to run a completely detached process?

I currently have a key binding for calling os.execute for the bash command


where $DIR is the current directory of the nvim process. This almost does what I want, but not quite, the child process is still attached to my currently running terminal. Therefore, if I try to close the terminal in which nvim is running, it hangs until I close the child window.

Is there a way to get it to run a completely detached process? I tried $TERMINAL $DIR &; disown, but that’s invalid syntax.

Update: I found a solution for kitty specifically: it has a --detach flag. A more general solution would still be appreciated.

I think you could try

nohup $TERMINAL $DIR &