greptile 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/greptile-fix +39 -3
- package/greptile-fix.applescript +8 -34
- package/package.json +1 -1
- package/preuninstall.sh +5 -0
package/greptile-fix
CHANGED
|
@@ -215,8 +215,44 @@ log "Creating runner script for: $REPO_PATH (IDE: $IDE)"
|
|
|
215
215
|
RUNNER=$(create_runner_script "$REPO_PATH" "$PROMPT" "$IDE")
|
|
216
216
|
log "Runner script: $RUNNER"
|
|
217
217
|
|
|
218
|
-
#
|
|
219
|
-
#
|
|
220
|
-
|
|
218
|
+
# Detect the user's terminal app using lsappinfo (no permissions needed).
|
|
219
|
+
# Prefer the frontmost app if it's a known terminal, else first running terminal, else Terminal.
|
|
220
|
+
detect_terminal() {
|
|
221
|
+
# Map of process names to "open -a" app names
|
|
222
|
+
local process_names=("iTerm2" "Ghostty" "Warp" "kitty" "WezTerm" "Alacritty" "Terminal")
|
|
223
|
+
local app_names=( "iTerm" "Ghostty" "Warp" "kitty" "WezTerm" "Alacritty" "Terminal")
|
|
224
|
+
|
|
225
|
+
# Check if frontmost app is a terminal
|
|
226
|
+
local front_asn
|
|
227
|
+
front_asn=$(lsappinfo front 2>/dev/null)
|
|
228
|
+
if [ -n "$front_asn" ]; then
|
|
229
|
+
local front_name
|
|
230
|
+
front_name=$(lsappinfo info -only name "$front_asn" 2>/dev/null | sed 's/.*="\(.*\)"/\1/')
|
|
231
|
+
for i in "${!process_names[@]}"; do
|
|
232
|
+
if [ "$front_name" = "${process_names[$i]}" ]; then
|
|
233
|
+
echo "${app_names[$i]}"
|
|
234
|
+
return
|
|
235
|
+
fi
|
|
236
|
+
done
|
|
237
|
+
fi
|
|
238
|
+
|
|
239
|
+
# Check for first running terminal
|
|
240
|
+
local running
|
|
241
|
+
running=$(lsappinfo list 2>/dev/null)
|
|
242
|
+
for i in "${!process_names[@]}"; do
|
|
243
|
+
if echo "$running" | grep -q "\"${process_names[$i]}\""; then
|
|
244
|
+
echo "${app_names[$i]}"
|
|
245
|
+
return
|
|
246
|
+
fi
|
|
247
|
+
done
|
|
248
|
+
|
|
249
|
+
echo "Terminal"
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
TERM_APP=$(detect_terminal)
|
|
253
|
+
log "Detected terminal: $TERM_APP"
|
|
254
|
+
|
|
255
|
+
# Print terminal app and runner path (two lines) — the AppleScript reads both.
|
|
256
|
+
echo "$TERM_APP"
|
|
221
257
|
echo "$RUNNER"
|
|
222
258
|
log "Done"
|
package/greptile-fix.applescript
CHANGED
|
@@ -5,45 +5,19 @@
|
|
|
5
5
|
-- Flow:
|
|
6
6
|
-- 1. macOS sends us the greptile:// URL
|
|
7
7
|
-- 2. We call greptile-fix CLI to parse the URL, resolve the repo path, and create a runner script
|
|
8
|
-
-- 3. greptile-fix
|
|
9
|
-
--
|
|
8
|
+
-- 3. greptile-fix detects the user's terminal (via lsappinfo) and prints two lines:
|
|
9
|
+
-- line 1: terminal app name (e.g. "iTerm", "Ghostty", "Terminal")
|
|
10
|
+
-- line 2: runner script path
|
|
11
|
+
-- 4. We open the runner script with "open -a <terminal>"
|
|
10
12
|
|
|
11
13
|
on open location theURL
|
|
12
14
|
try
|
|
13
|
-
-- Call greptile-fix
|
|
14
|
-
set
|
|
15
|
+
-- Call greptile-fix; it prints terminal app name (line 1) and runner path (line 2) to stdout
|
|
16
|
+
set outputLines to do shell script "PATH=/opt/homebrew/bin:/usr/local/bin:$PATH greptile-fix " & quoted form of theURL & " 2>> /tmp/greptile-fix.log"
|
|
17
|
+
|
|
18
|
+
set {termApp, runnerPath} to {paragraph 1 of outputLines, paragraph 2 of outputLines}
|
|
15
19
|
|
|
16
20
|
if runnerPath is not "" then
|
|
17
|
-
-- Detect terminal app: prefer frontmost if it's a terminal, else first running terminal, else Terminal.app
|
|
18
|
-
set termApp to "Terminal"
|
|
19
|
-
set knownTerminals to {"iTerm2", "Ghostty", "Warp", "kitty", "WezTerm", "Alacritty", "Terminal"}
|
|
20
|
-
-- Map process names to the app name expected by "open -a"
|
|
21
|
-
-- (iTerm2's process name is "iTerm2" but the app name is "iTerm")
|
|
22
|
-
set termAppNames to {"iTerm", "Ghostty", "Warp", "kitty", "WezTerm", "Alacritty", "Terminal"}
|
|
23
|
-
try
|
|
24
|
-
tell application "System Events"
|
|
25
|
-
set frontName to name of first application process whose frontmost is true
|
|
26
|
-
set runningApps to name of every application process whose background only is false
|
|
27
|
-
end tell
|
|
28
|
-
-- If the frontmost app is a known terminal, use it
|
|
29
|
-
set foundFront to false
|
|
30
|
-
repeat with i from 1 to count of knownTerminals
|
|
31
|
-
if frontName is equal to item i of knownTerminals then
|
|
32
|
-
set termApp to item i of termAppNames
|
|
33
|
-
set foundFront to true
|
|
34
|
-
exit repeat
|
|
35
|
-
end if
|
|
36
|
-
end repeat
|
|
37
|
-
-- Otherwise pick the first running terminal we recognize
|
|
38
|
-
if not foundFront then
|
|
39
|
-
repeat with i from 1 to count of knownTerminals
|
|
40
|
-
if item i of knownTerminals is in runningApps then
|
|
41
|
-
set termApp to item i of termAppNames
|
|
42
|
-
exit repeat
|
|
43
|
-
end if
|
|
44
|
-
end repeat
|
|
45
|
-
end if
|
|
46
|
-
end try
|
|
47
21
|
do shell script "open -a " & quoted form of termApp & " " & quoted form of runnerPath
|
|
48
22
|
end if
|
|
49
23
|
on error errMsg
|
package/package.json
CHANGED
package/preuninstall.sh
CHANGED