54 lines
1.4 KiB
Bash
Executable File
54 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Required parameters:
|
|
# @raycast.schemaVersion 1
|
|
# @raycast.title Open CNB Remote VSCode
|
|
# @raycast.mode silent
|
|
|
|
# Optional parameters:
|
|
# @raycast.icon 🖥️
|
|
# @raycast.packageName @kevisual/raycast
|
|
|
|
# Documentation:
|
|
# @raycast.description SSH to CNB host, fuzzy select a project with fzf, then open it in VSCode Remote
|
|
# @raycast.author abearxiong
|
|
# @raycast.authorURL https://raycast.com/abearxiong
|
|
|
|
CONFIG_FILE="$HOME/.config/my-raycast/cnb-host"
|
|
FZF_BIN="/usr/local/bin/fzf"
|
|
|
|
if [[ ! -f "$CONFIG_FILE" ]]; then
|
|
osascript -e 'display alert "CNB Host 未配置" message "请先运行 Set CNB Host 脚本设置远程地址"'
|
|
exit 1
|
|
fi
|
|
|
|
CNB_HOST=$(cat "$CONFIG_FILE" | tr -d '[:space:]')
|
|
|
|
if [[ -z "$CNB_HOST" ]]; then
|
|
osascript -e 'display alert "CNB Host 为空" message "请先运行 Set CNB Host 脚本设置远程地址"'
|
|
exit 1
|
|
fi
|
|
|
|
CMD="ssh '$CNB_HOST' 'find /workspace/projects /workspace/docker -maxdepth 1 -mindepth 1 -type d 2>/dev/null' | $FZF_BIN --prompt='CNB Remote > ' | xargs -I{} open 'vscode://vscode-remote/ssh-remote+${CNB_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
|