Add ssh-open: open iTerm2 window with 6 SSH tabs
Opens a new iTerm2 window with tabs that ssh into ta, vrc, aws-vanhoa, toc, oc, tk in order. Tab colors are applied by the ssh() override in ~/.zshrc (per-host); a small delay between tab creations lets iTerm process the color OSC reliably. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env bash
|
||||
# ssh-open — mở cửa sổ iTerm2 mới với 6 tab, mỗi tab ssh vào 1 host theo thứ tự.
|
||||
# Màu tab do ~/.zshrc (hàm ssh() override) tự set khi ssh chạy trong tab.
|
||||
# delay giữa các tab để iTerm kịp xử lý OSC đổi màu (tránh mất màu khi tạo tab liên tục).
|
||||
set -euo pipefail
|
||||
|
||||
# Danh sách host theo thứ tự (alias từ ~/.ssh/config).
|
||||
HOSTS=(ta vrc aws-vanhoa toc oc tk)
|
||||
|
||||
# Sinh AppleScript list: {"ta","vrc",...}
|
||||
alist="$(printf '"%s",' "${HOSTS[@]}")"
|
||||
alist="{${alist%,}}"
|
||||
|
||||
osascript <<APPLESCRIPT
|
||||
tell application "iTerm"
|
||||
activate
|
||||
set theHosts to $alist
|
||||
set newWindow to (create window with default profile)
|
||||
delay 0.5
|
||||
tell newWindow
|
||||
-- Tab đầu: dùng tab gốc của cửa sổ mới.
|
||||
tell current session of current tab
|
||||
write text ("ssh " & item 1 of theHosts)
|
||||
end tell
|
||||
-- Các host còn lại: mỗi host 1 tab mới.
|
||||
repeat with i from 2 to (count of theHosts)
|
||||
set t to (create tab with default profile)
|
||||
delay 0.5
|
||||
tell current session of t
|
||||
write text ("ssh " & item i of theHosts)
|
||||
end tell
|
||||
end repeat
|
||||
end tell
|
||||
end tell
|
||||
APPLESCRIPT
|
||||
Reference in New Issue
Block a user