# detach — run a command fully free of the terminal. # New session (setsid), stdio to /dev/null, backgrounded, disowned. # Closing the terminal will not kill the process or print its logs. # # Usage: # detach brave # detach gimp ~/pic.png # Escape hatch (run attached): command brave OR DETACH_OFF=1 brave function detach --description 'Run command fully detached from the terminal' if test (count $argv) -eq 0 echo 'usage: detach [args...]' >&2 return 1 end # setsid: new session, no controlling TTY # /dev/null 2>&1: no terminal I/O, no SIGHUP-on-close noise # & + disown: fish will not job-control or SIGHUP the process on exit setsid $argv /dev/null 2>&1 & disown end