Compare commits
2 Commits
ad27c0cc94
...
f6943b7f9a
| Author | SHA1 | Date | |
|---|---|---|---|
| f6943b7f9a | |||
| 1468a9316a |
7
AGENTS.md
Normal file
7
AGENTS.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# raycast
|
||||
|
||||
对于 raycast 的使用,好用,但是有一些脚本还是需要自己写的。
|
||||
|
||||
- `./applescript` 是一些 applescript 脚本
|
||||
- `./sh` 是一些 shell 脚本
|
||||
- `./js` 是一些 javascript或者typescript 脚本
|
||||
@@ -1,3 +1,7 @@
|
||||
# raycast
|
||||
|
||||
对于 raycast 的使用,好用,但是有一些脚本还是需要自己写的。
|
||||
|
||||
- `./applescript` 是一些 applescript 脚本
|
||||
- `./sh` 是一些 shell 脚本
|
||||
- `./js` 是一些 javascript或者typescript 脚本
|
||||
53
sh/open-cnb-remote-vscode.sh
Executable file
53
sh/open-cnb-remote-vscode.sh
Executable file
@@ -0,0 +1,53 @@
|
||||
#!/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
|
||||
40
sh/open-vscode-remote.sh
Executable file
40
sh/open-vscode-remote.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Required parameters:
|
||||
# @raycast.schemaVersion 1
|
||||
# @raycast.title Open VSCode Remote
|
||||
# @raycast.mode silent
|
||||
|
||||
# Optional parameters:
|
||||
# @raycast.icon 🖥️
|
||||
# @raycast.packageName @kevisual/raycast
|
||||
|
||||
# Documentation:
|
||||
# @raycast.description SSH to diana, fuzzy select a project with fzf, then open it in VSCode Remote
|
||||
# @raycast.author abearxiong
|
||||
# @raycast.authorURL https://raycast.com/abearxiong
|
||||
|
||||
FZF_BIN="/usr/local/bin/fzf"
|
||||
|
||||
CMD="ssh diana 'find /root/workspace/projects /root/workspace/docker -maxdepth 1 -mindepth 1 -type d 2>/dev/null' | $FZF_BIN --prompt='VSCode Remote > ' | xargs -I{} open 'vscode://vscode-remote/ssh-remote+diana{}'"
|
||||
|
||||
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
|
||||
45
sh/set-cnb-host.sh
Executable file
45
sh/set-cnb-host.sh
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Required parameters:
|
||||
# @raycast.schemaVersion 1
|
||||
# @raycast.title Set CNB Host
|
||||
# @raycast.mode compact
|
||||
|
||||
# Optional parameters:
|
||||
# @raycast.icon ⚙️
|
||||
# @raycast.packageName @kevisual/raycast
|
||||
# @raycast.argument1 { "type": "text", "placeholder": "user@host or vscode://vscode-remote/ssh-remote+user@host/..." }
|
||||
|
||||
# Documentation:
|
||||
# @raycast.description Set the CNB SSH remote host used by Open CNB Remote VSCode
|
||||
# @raycast.author abearxiong
|
||||
# @raycast.authorURL https://raycast.com/abearxiong
|
||||
|
||||
CONFIG_DIR="$HOME/.config/my-raycast"
|
||||
CONFIG_FILE="$CONFIG_DIR/cnb-host"
|
||||
|
||||
if [[ -z "$1" ]]; then
|
||||
echo "请提供 CNB host 或 VSCode Remote URL"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
INPUT="$1"
|
||||
|
||||
# 如果是 vscode:// 协议地址,提取 ssh-remote+ 后面的 host 部分
|
||||
if [[ "$INPUT" == vscode://* ]]; then
|
||||
# 提取 ssh-remote+<host> 后的内容,去掉路径部分
|
||||
HOST=$(echo "$INPUT" | sed 's|.*ssh-remote+||' | cut -d'/' -f1)
|
||||
else
|
||||
HOST="$INPUT"
|
||||
fi
|
||||
|
||||
HOST=$(echo "$HOST" | tr -d '[:space:]')
|
||||
|
||||
if [[ -z "$HOST" ]]; then
|
||||
echo "无法解析 host,请检查输入"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$CONFIG_DIR"
|
||||
echo "$HOST" > "$CONFIG_FILE"
|
||||
echo "CNB host 已保存:$HOST"
|
||||
Reference in New Issue
Block a user