-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwarp
More file actions
executable file
·78 lines (64 loc) · 2.02 KB
/
warp
File metadata and controls
executable file
·78 lines (64 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
# warp - SSH connection manager with encrypted configuration
set -euo pipefail
# gum control
BORDER=none
ALIGN=left
MARGIN="0 0"
PADDING="0 0"
#
# Dependency checks
verify_dependencies() {
local missing=()
local all_ok=true
# Check for yq (YAML processor)
if ! command -v yq &> /dev/null; then
missing+=("yq (https://github.com/mikefarah/yq)")
all_ok=false
fi
# Check for gum (interactive prompts)
if ! command -v gum &> /dev/null; then
missing+=("gum (https://github.com/charmbracelet/gum)")
all_ok=false
fi
# Visual feedback
if $all_ok; then
gum style --foreground 10 --border none --align left --margin "0 0" --padding "0 0" "✓ dependencies OK"
else
echo "Missing dependencies:" >&2
for dep in "${missing[@]}"; do
echo " - $dep" >&2
done
exit 1
fi
}
# Configuration management
load_config() {
local warp_file="$HOME/data/warp/credentials.yml"
# Load configuration values
host=$(yq .host "$warp_file")
user=$(yq .user "$warp_file")
port=$(yq .port "$warp_file")
# Validate configuration
if [[ $? -ne 0 ]] || [[ -z "$host" || -z "$user" || -z "$port" ]]; then
echo "ERROR: Missing configuration values" >&2
echo "Required fields: .host, .user, .port" >&2
exit 1
fi
gum style --foreground 10 --border none --align left --margin "0 0" --padding "0 0" "✓ config OK"
}
# Main function
main() {
verify_dependencies
load_config
# Debug output
gum style --foreground 212 --border-foreground 212 --border double \
--align center --width 30 --margin "0 0" --padding "0 0" \
"CONFIGURATION LOADED" \
"$(gum join --horizontal "HOST: " "$(gum style --foreground 99 "$host")")" \
"$(gum join --horizontal "USER: " "$(gum style --foreground 99 "$user")")" \
"$(gum join --horizontal "PORT: " "$(gum style --foreground 99 "$port")")"
# Execute SSH connection
ssh -p $port $user@$host
}
main "$@"