-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathopen_setup.sh
More file actions
executable file
Β·142 lines (121 loc) Β· 4.53 KB
/
open_setup.sh
File metadata and controls
executable file
Β·142 lines (121 loc) Β· 4.53 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/bash
# Script to open setup.sh in a new terminal window
# This handles different terminal emulators and operating systems gracefully
set -e
echo "π Opening Databricks App Template Setup..."
# Get the directory of this script
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Function to detect the operating system
get_os() {
case "$(uname -s)" in
Darwin*) echo "macOS" ;;
Linux*) echo "Linux" ;;
MINGW*|MSYS*|CYGWIN*) echo "Windows" ;;
*) echo "Unknown" ;;
esac
}
# Function to check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Function to check if an macOS app exists
app_exists_macos() {
[ -d "/Applications/$1.app" ] || [ -d "$HOME/Applications/$1.app" ]
}
OS=$(get_os)
# Create a temporary file to signal when setup is complete (for auto-close functionality)
TEMP_FILE=$(mktemp)
case "$OS" in
macOS)
# Try different terminal emulators in order of preference
if app_exists_macos "iTerm"; then
echo "π± Opening in iTerm..."
osascript <<EOF
tell application "iTerm"
create window with default profile
tell current session of current window
write text "cd '$SCRIPT_DIR' && ./setup.sh --auto-close '$TEMP_FILE' && exit"
end tell
end tell
EOF
elif app_exists_macos "Warp"; then
echo "π± Opening in Warp..."
# Warp doesn't have great AppleScript support, so we use open command
open -a Warp "$SCRIPT_DIR"
echo "β οΈ Please run './setup.sh' in the Warp window that just opened"
elif app_exists_macos "Terminal"; then
echo "π± Opening in Terminal..."
osascript <<EOF
tell application "Terminal"
do script "cd '$SCRIPT_DIR' && ./setup.sh --auto-close '$TEMP_FILE' && exit"
activate
end tell
EOF
else
echo "β No supported terminal emulator found on macOS"
echo "π Supported terminals: iTerm, Terminal, Warp"
echo ""
echo "π‘ Please open a terminal manually and run:"
echo " cd '$SCRIPT_DIR'"
echo " ./setup.sh"
exit 1
fi
;;
Linux)
# Try different terminal emulators common on Linux
if command_exists gnome-terminal; then
echo "π± Opening in GNOME Terminal..."
gnome-terminal -- bash -c "cd '$SCRIPT_DIR' && ./setup.sh; exec bash"
elif command_exists konsole; then
echo "π± Opening in Konsole..."
konsole -e bash -c "cd '$SCRIPT_DIR' && ./setup.sh; exec bash"
elif command_exists xfce4-terminal; then
echo "π± Opening in XFCE Terminal..."
xfce4-terminal -e "bash -c 'cd $SCRIPT_DIR && ./setup.sh; exec bash'"
elif command_exists xterm; then
echo "π± Opening in XTerm..."
xterm -e "cd '$SCRIPT_DIR' && ./setup.sh; bash"
else
echo "β No supported terminal emulator found on Linux"
echo "π Supported terminals: gnome-terminal, konsole, xfce4-terminal, xterm"
echo ""
echo "π‘ Please open a terminal manually and run:"
echo " cd '$SCRIPT_DIR'"
echo " ./setup.sh"
exit 1
fi
;;
Windows)
echo "π± Opening in Windows Terminal or Command Prompt..."
# For Windows, we'll use start command
if command_exists cmd.exe; then
cmd.exe /c "start cmd /k cd /d $SCRIPT_DIR && bash setup.sh"
else
echo "β Could not open terminal on Windows"
echo ""
echo "π‘ Please open a terminal manually and run:"
echo " cd '$SCRIPT_DIR'"
echo " ./setup.sh"
exit 1
fi
;;
*)
echo "β Unsupported operating system: $(uname -s)"
echo ""
echo "π‘ Please open a terminal manually and run:"
echo " cd '$SCRIPT_DIR'"
echo " ./setup.sh"
exit 1
;;
esac
# For macOS terminals that support auto-close, wait for completion
if [ "$OS" = "macOS" ] && { app_exists_macos "iTerm" || app_exists_macos "Terminal"; }; then
echo "β³ Waiting for setup to complete..."
# Wait for the setup script to signal completion
while [ ! -f "$TEMP_FILE" ] || [ "$(cat "$TEMP_FILE" 2>/dev/null)" != "setup_complete" ]; do
sleep 1
done
# Clean up
rm -f "$TEMP_FILE"
echo "β
Setup completed!"
fi