# Auto-detach GUI apps launched from the shell.
# Typing `brave`, `zathura`, etc. never ties the process to the terminal.
#
# Escape hatches:
# command brave # real binary, attached
# DETACH_OFF=1 brave # same, for wrapped names
# detach <cmd> # explicit (also works for anything not listed)
if not status is-interactive
exit
end
# Apps that open a window and have no reason to own a terminal.
# Keep this list GUI-only. Never put TUIs (nvim, btop, nnn, dmenu, rofi, fzf).
set -g DETACH_GUI_APPS \
brave brave-browser chromium firefox librewolf vivaldi ungoogled-chromium helium \
nyxt qutebrowser surf torbrowser-launcher \
zathura nsxiv imv sxiv feh mpv vlc \
gimp inkscape libreoffice soffice \
thunar pcmanfm nautilus dolphin nemo \
pavucontrol pavucontrol-qt blueman-manager arandr lxappearance qt5ct qt6ct \
nm-connection-editor gparted \
obs qbittorrent transmission-gtk filezilla \
keepassxc bitwarden \
cursor zed \
steam discord signal-desktop telegram-desktop \
anki gthumb eog \
wireshark wireshark-qt \
virtualbox VirtualBox \
hakuneko-desktop \
mousepad xed leafpad \
galculator \
mirror-browser
function __detach_gui_wrap --description 'Define a detached wrapper for a GUI binary'
set -l name $argv[1]
# Only wrap if a real binary exists (avoid wrapping missing tools)
if not command -q $name
return
end
# Do not clobber an existing hand-written function (e.g. special wrappers)
if functions -q $name
return
end
# Dynamic function: name becomes a detached launcher; `command name` is the escape hatch
eval "
function $name --wraps=$name --description '$name (detached from terminal)'
if set -q DETACH_OFF
command $name \$argv
else
detach command $name \$argv
end
end
"
end
for __detach_app in $DETACH_GUI_APPS
__detach_gui_wrap $__detach_app
end
set -e __detach_app