Last active
June 19, 2026 07:32
-
-
Save ZaLiTHkA/f678ae3b73c0dfb93d1838ed49a9cc0d to your computer and use it in GitHub Desktop.
this file should be sourced into your current environment through something like `~/.bashrc` or `~/.zshrc`, specifically after your IDE launcher scripts have been added to `PATH`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Related YouTrack issues: | |
| # TBX-4599: https://youtrack.jetbrains.com/issue/TBX-4599 | |
| # TBX-12190: https://youtrack.jetbrains.com/issue/TBX-12190 | |
| # Force JetBrains IDE launchers to detach from the terminal and respect the current directory, regardless of install method (Toolbox or Homebrew) or OS (Linux or macOS). | |
| function jb_detach { | |
| emulate -L zsh | |
| local launcher=$1; shift | |
| # Absolutize any argument that names an existing path, so launchers that go through `open`/LaunchServices (which ignore cwd) still open the right thing. | |
| local -a args; local a | |
| for a in "$@"; do | |
| [[ -e $a ]] && args+=("${a:A}") || args+=("$a") | |
| done | |
| # nohup + & + disown = detach + survive shell exit + leave the job table clean. | |
| nohup "$launcher" "${args[@]}" &>/dev/null & disown | |
| } | |
| # Shadow every installed JetBrains launcher found on PATH. `whence -p` does a PATH-only lookup, so it returns the real launcher even though we define a function of the same name (no recursion), and it unifies Toolbox and Homebrew installs since both just drop a same-named command somewhere on PATH. | |
| for _jb in idea webstorm pycharm goland clion datagrip rubymine phpstorm rider rustrover aqua dataspell studio; do | |
| whence -p $_jb &>/dev/null || continue | |
| functions[$_jb]="jb_detach \$(whence -p $_jb) \"\$@\"" | |
| done | |
| unset _jb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment