-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.zsh
More file actions
67 lines (60 loc) · 2.18 KB
/
setup.zsh
File metadata and controls
67 lines (60 loc) · 2.18 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
#!/bin/sh
# Function to check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Check if Homebrew is installed
echo "Checking if Homebrew is installed..."
if ! command_exists brew; then
echo "⚠️ Homebrew is not installed."
echo "🛠️ Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
else
echo "✅ Homebrew is already installed."
fi
# Check if rustup-init is installed
echo "Checking if Rust/Cargo is installed..."
if ! command_exists rustup-init; then
echo "⚠️ rustup-init is not installed."
echo "🛠️ Installing rustup-init..."
brew install rustup-init
else
echo "✅ Rust is installed."
fi
# Initialize rustup (this only needs to be done once)
echo "Checking if Rust is initialized..."
if ! command_exists rustup; then
echo "🛠️ Initializing rustup..."
rustup-init -y
source "$HOME"/.cargo/env
else
echo "✅ Rustup is initialized."
fi
# Check if "tod" is installed
echo "Checking if \"Tod\" is installed..."
if ! command_exists tod; then
echo "⚠️ \"Tod\" is not installed. "
echo "🛠️ Installing \"Tod\"..."
cargo install tod
else
echo "✅ \"Tod\" is installed."
fi
# Run "tod config check-version" and if successful, run "t q -c Alfred 'Test Task'"
if command_exists brew && command_exists rustup && command_exists tod; then
echo "✅ All required tools are installed. Running \"tod config check-version\"..."
if tod config check-version; then
echo "✅ Version check successful."
echo "Submitting Test Task to your Inbox..."
if tod task q -c "Alfred Test Task"; then
echo "✅ Test Task created! Check your Todoist Inbox."
else
echo "❌ Task Creation failed. Resetting config"
tod config reset
echo "❌ Config deleted. Check your internet connectivity, API key, or run 'tod config reset' and run again."
fi
else
echo "❌ Version check failed. Check connectivity and try again."
fi
else
echo "❌ One or more tools are not installed correctly. Retry, install manually, or open a bug report."
fi