fedef5dbd5f8ffef16815cb3a2c611eb0f7f00b1

Author
Marc Cornellà <hello@mcornella.com>
Committer
Marc Cornellà <hello@mcornella.com>
Date

Message

fix(xcode): open Xcode in current Desk if already open in another (#10384)

Fixes #10384

Diff

 1diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh
 2index 5d1f901a3ad30fd6f184252c039572645298f7c5..f09434e6916c3c12877832ec79de45fb53a08028 100644
 3--- a/plugins/xcode/xcode.plugin.zsh
 4+++ b/plugins/xcode/xcode.plugin.zsh
 5@@ -17,6 +17,13 @@ function xc {
 6   local active_path
 7   active_path=${"$(xcode-select -p)"%%/Contents/Developer*}
 8   echo "Found ${xcode_files[1]}. Opening with ${active_path}"
 9+
10+  # If Xcode is already opened in another Desk, we need this double call
11+  # with -g to open the project window in the current Desk and focus it.
12+  # See https://github.com/ohmyzsh/ohmyzsh/issues/10384
13+  if command pgrep -q "^Xcode"; then
14+    open -g -a "$active_path" "${xcode_files[1]}"
15+  fi
16   open -a "$active_path" "${xcode_files[1]}"
17 }
18