refactor: migrate all scripts and utils from bash to zsh (#3)

This commit is contained in:
Esteban Vincent
2026-05-19 14:57:38 +02:00
committed by GitHub
parent 071f1df0ba
commit 6198cdb0e1
9 changed files with 28 additions and 28 deletions
+11 -11
View File
@@ -7,23 +7,23 @@ Personal [Raycast](https://raycast.com) script collection.
```
scripts/ # Raycast script commands
envs/ # Per-script .env files (gitignored)
utils.sh # Shared helper: load_env
utils.zsh # Shared helper: load_env
```
## Scripts
| Script | Icon | Description |
| -------------------- | ---- | ------------------------------------------------------ |
| `base64.sh` | 🔡 | Encode/decode base64 — text, file path, or clipboard |
| `get_graph_user.sh` | 👤 | Fetch MS Graph user info by ID or UPN |
| `imgflip-meme.sh` | 🖼️ | Generate a meme via imgflip webhook, copy to clipboard |
| `ipv4-get.sh` | 🌐 | Copy public IPv4 to clipboard |
| `no-as-a-service.sh` | ❌ | Random rejection reason from No-as-a-Service |
| `x.sh` | 🤖 | Copy Bruno ✕ character to clipboard |
| --------------------- | ---- | ------------------------------------------------------ |
| `base64.zsh` | 🔡 | Encode/decode base64 — text, file path, or clipboard |
| `get_graph_user.zsh` | 👤 | Fetch MS Graph user info by ID or UPN |
| `imgflip-meme.zsh` | 🖼️ | Generate a meme via imgflip webhook, copy to clipboard |
| `ipv4-get.zsh` | 🌐 | Copy public IPv4 to clipboard |
| `no-as-a-service.zsh` | ❌ | Random rejection reason from No-as-a-Service |
| `x.zsh` | 🤖 | Copy Bruno ✕ character to clipboard |
## Environment files
Scripts that need secrets use `load_env` from `utils.sh`. Each script auto-loads `envs/<script-name>.env` at runtime.
Scripts that need secrets use `load_env` from `utils.zsh`. Each script auto-loads `envs/<script-name>.env` at runtime.
**Example**`envs/get_graph_user.env`:
@@ -44,10 +44,10 @@ N8N_WEBHOOK_IMGFLIP_API_KEY="..."
## Adding a new script
1. Create `scripts/my-script.sh` with Raycast metadata headers.
1. Create `scripts/my-script.zsh` with Raycast metadata headers.
2. Source the helper and call `load_env`:
```bash
source "$HOME/Raycast/utils.sh"
source "$HOME/Raycast/utils.zsh"
load_env VAR1 VAR2 || exit 1
```
3. Create the matching `envs/my-script.env` with the required variables.
+1 -1
View File
@@ -1,2 +1,2 @@
# Each script that needs to use the environment variables should have a env file with the same name as the script
# For example, if you have a script called `train.sh`, you should create a file called `train.env`.
# For example, if you have a script called `train.zsh`, you should create a file called `train.env`.
+1 -1
View File
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/zsh
# Required parameters:
# @raycast.schemaVersion 1
@@ -1,9 +1,9 @@
#!/bin/bash
#!/bin/zsh
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Get Graph User
# @raycast.mode silent
# @raycast.mode compact
# @raycast.argument1 { "type": "text", "placeholder": "User ID or UPN" }
# Optional parameters:
@@ -16,7 +16,7 @@
USER_ID="$1"
# shellcheck source=/dev/null
source "$HOME/Raycast/utils.sh"
source "$HOME/Raycast/utils.zsh"
load_env AZURE_TENANT_ID AZURE_CLIENT_ID AZURE_CLIENT_SECRET || exit 1
TOKEN_RESPONSE=$(curl -s -w "\n%{http_code}" \
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/zsh
# Required parameters:
# @raycast.schemaVersion 1
@@ -14,7 +14,7 @@
# @raycast.author Esteban Vincent
# shellcheck source=/dev/null
source "$HOME/Raycast/utils.sh"
source "$HOME/Raycast/utils.zsh"
load_env N8N_WEBHOOK_BASE_URL N8N_WEBHOOK_IMGFLIP_API_KEY || exit 1
QUERY="$1"
+1 -1
View File
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/zsh
# Required parameters:
# @raycast.schemaVersion 1
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/zsh
# Required parameters:
# @raycast.schemaVersion 1
+1 -1
View File
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/zsh
# Required parameters:
# @raycast.schemaVersion 1
+6 -6
View File
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/zsh
# Helper: source this file, then call load_env
# Usage: source "$HOME/Raycast/utils/load_env.sh"
# load_env VAR1 VAR2 VAR3 || exit 1
@@ -6,7 +6,7 @@
load_env() {
local caller
caller="$(basename "${BASH_SOURCE[1]}" .sh)"
caller="$(basename "${funcfiletrace[1]%:*}" .zsh)"
LOADED_ENV_FILE="$HOME/Raycast/envs/${caller}.env"
if [[ ! -f "$LOADED_ENV_FILE" ]]; then
@@ -27,15 +27,15 @@ load_env() {
if [[ "$value" == \"*\" ]]; then
value="${value#\"}"
value="${value%\"}"
elif [[ "$value" == \'*\' ]]; then
value="${value#\'}"
value="${value%\'}"
elif [[ "$value" == "'"*"'" ]]; then
value="${value#"'"}"
value="${value%"'"}"
fi
export "$key=$value"
done < "$LOADED_ENV_FILE"
for var in "$@"; do
if [[ -z "${!var}" ]]; then
if [[ -z "${(P)var}" ]]; then
echo "❌ Missing $var in .env"
return 1
fi