Skip to content

Commit

Permalink
Updating to single zsh script for td-setup
Browse files Browse the repository at this point in the history
  • Loading branch information
stacksjb committed May 21, 2024
1 parent a3f3be5 commit 5187f0b
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 26 deletions.
74 changes: 48 additions & 26 deletions info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<array>
<dict>
<key>destinationuid</key>
<string>521CFF45-3C8D-45B1-AF7F-35E2A6440958</string>
<string>F2D19A0D-E9EA-45D7-A87E-4837EF95FCEB</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
Expand Down Expand Up @@ -386,27 +386,6 @@ fi</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>argumenttype</key>
<integer>2</integer>
<key>keyword</key>
<string>td-setup</string>
<key>subtext</key>
<string>Run Intial Config/Check Script</string>
<key>text</key>
<string>Todo Setup</string>
<key>withspace</key>
<false/>
</dict>
<key>type</key>
<string>alfred.workflow.input.keyword</string>
<key>uid</key>
<string>4CA015AF-C9E1-4CF2-AC7A-B4CB3172EDF9</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
Expand Down Expand Up @@ -442,6 +421,42 @@ fi</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>escaping</key>
<integer>65</integer>
<key>script</key>
<string>zsh "{const:alfred_preferences}/workflows/{const:alfred_workflow_uid}/setup.zsh"</string>
</dict>
<key>type</key>
<string>alfred.workflow.action.terminalcommand</string>
<key>uid</key>
<string>F2D19A0D-E9EA-45D7-A87E-4837EF95FCEB</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>argumenttype</key>
<integer>2</integer>
<key>keyword</key>
<string>td-setup</string>
<key>subtext</key>
<string>Run Intial Config/Check Script</string>
<key>text</key>
<string>Todo Setup</string>
<key>withspace</key>
<false/>
</dict>
<key>type</key>
<string>alfred.workflow.input.keyword</string>
<key>uid</key>
<string>4CA015AF-C9E1-4CF2-AC7A-B4CB3172EDF9</string>
<key>version</key>
<integer>1</integer>
</dict>
</array>
<key>readme</key>
<string>Alfred Tod workflow
Expand Down Expand Up @@ -469,16 +484,16 @@ Task Prefix/Suffix can be used if you want to always (be default) add a specific
<key>note</key>
<string>Initial TOD Setup and Configuration</string>
<key>xpos</key>
<real>50</real>
<real>85</real>
<key>ypos</key>
<real>595</real>
<real>1005</real>
</dict>
<key>521CFF45-3C8D-45B1-AF7F-35E2A6440958</key>
<dict>
<key>xpos</key>
<real>315</real>
<real>420</real>
<key>ypos</key>
<real>660</real>
<real>650</real>
</dict>
<key>52C792D5-43B7-44E2-82BD-B5D0B35545F7</key>
<dict>
Expand Down Expand Up @@ -557,6 +572,13 @@ Task Prefix/Suffix can be used if you want to always (be default) add a specific
<key>ypos</key>
<real>340</real>
</dict>
<key>F2D19A0D-E9EA-45D7-A87E-4837EF95FCEB</key>
<dict>
<key>xpos</key>
<real>355</real>
<key>ypos</key>
<real>1005</real>
</dict>
<key>FCD1F155-6CDE-403B-80E6-E7A517D65717</key>
<dict>
<key>xpos</key>
Expand Down
67 changes: 67 additions & 0 deletions setup.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,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

0 comments on commit 5187f0b

Please sign in to comment.