47 lines
1.2 KiB
Bash
Executable File
47 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Required parameters:
|
|
# @raycast.schemaVersion 1
|
|
# @raycast.title Open Ruten Remote VSCode
|
|
# @raycast.mode silent
|
|
|
|
# Optional parameters:
|
|
# @raycast.icon 🖥️
|
|
# @raycast.packageName @kevisual/raycast
|
|
|
|
# Documentation:
|
|
# @raycast.description SSH to Ruten host, fuzzy select a project with fzf, then open it in VSCode Remote
|
|
# @raycast.author abearxiong
|
|
# @raycast.authorURL https://raycast.com/abearxiong
|
|
|
|
FZF_BIN="fzf"
|
|
RUTEN_HOST=ruten-dev
|
|
|
|
if [[ -z "$RUTEN_HOST" ]]; then
|
|
osascript -e 'display alert "Ruten Host 为空" message "请先运行 Set Ruten Host 脚本设置远程地址"'
|
|
exit 1
|
|
fi
|
|
|
|
CMD="ssh '$RUTEN_HOST' 'find /workspace/projects /workspace/docker -maxdepth 1 -type d 2>/dev/null' | $FZF_BIN --prompt='Ruten Remote > ' | xargs -I{} open 'vscode://vscode-remote/ssh-remote+${RUTEN_HOST}{}'"
|
|
|
|
osascript <<OSASCRIPT
|
|
tell application "iTerm"
|
|
activate
|
|
try
|
|
set newWindow to (create window with default profile)
|
|
tell newWindow
|
|
tell current session
|
|
write text "$CMD"
|
|
end tell
|
|
end tell
|
|
on error
|
|
tell current window
|
|
create tab with default profile
|
|
tell current session
|
|
write text "$CMD"
|
|
end tell
|
|
end tell
|
|
end try
|
|
end tell
|
|
OSASCRIPT
|