Skip to content

Add shared shell helpers for Raycast wrappers #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions airtable-to-network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
# @raycast.author Nick Trombley
# @raycast.authorURL https://github.com/Aias

# Load zsh environment
source ~/.zshrc
# Load shell configuration
source "$(dirname "$0")/scripts/common.sh"
load_shell_config

# Get the directory where this script is located
SCRIPT_DIR="${0:a:h}"
set_script_dir "$0"

# Run the Python script using uv
cd "$SCRIPT_DIR/airtable-to-network" && uv run python airtable-to-network.py "$@"
7 changes: 4 additions & 3 deletions clean-transcript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
# @raycast.author Nick Trombley
# @raycast.description Clean an existing transcript using OpenAI to remove filler words and fix grammar

# Load zsh environment (includes environment variables)
source ~/.zshrc
# Load shell configuration (includes environment variables)
source "$(dirname "$0")/scripts/common.sh"
load_shell_config

# Get the directory where this script is located
SCRIPT_DIR="${0:a:h}"
set_script_dir "$0"

# Run the Bun/TypeScript cleaner
bun "$SCRIPT_DIR/audio-transcriber/clean-transcript.ts" "$@"
7 changes: 4 additions & 3 deletions clipboard-to-markdown.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
# @raycast.author Nick Trombley
# @raycast.authorURL https://github.com/Aias

# Load zsh environment
source ~/.zshrc
# Load shell configuration
source "$(dirname "$0")/scripts/common.sh"
load_shell_config

# Get the directory where this script is located
SCRIPT_DIR="${0:a:h}"
set_script_dir "$0"

# Run the TypeScript script
cd "$SCRIPT_DIR/clipboard-to-markdown" && yarn start
7 changes: 4 additions & 3 deletions clipboard-to-pdf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
# @raycast.author Nick Trombley
# @raycast.authorURL https://github.com/Aias

# Load zsh environment
source ~/.zshrc
# Load shell configuration
source "$(dirname "$0")/scripts/common.sh"
load_shell_config

# Get the directory where this script is located
SCRIPT_DIR="${0:a:h}"
set_script_dir "$0"

# Run the Node.js script
cd "$SCRIPT_DIR/clipboard-to-pdf" && node clipboard-to-pdf.js "$@"
7 changes: 4 additions & 3 deletions clipboard-to-print.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
# @raycast.author Nick Trombley
# @raycast.authorURL https://github.com/Aias

# Load zsh environment
source ~/.zshrc
# Load shell configuration
source "$(dirname "$0")/scripts/common.sh"
load_shell_config

# Get the directory where this script is located
SCRIPT_DIR="${0:a:h}"
set_script_dir "$0"

# Run the Node.js script
cd "$SCRIPT_DIR/clipboard-to-print" && node clipboard-to-print.js "$@"
7 changes: 4 additions & 3 deletions crawler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
# @raycast.author Nick Trombley
# @raycast.authorURL https://github.com/Aias

# Load zsh environment
source ~/.zshrc
# Load shell configuration
source "$(dirname "$0")/scripts/common.sh"
load_shell_config

# Get the directory where this script is located
SCRIPT_DIR="${0:a:h}"
set_script_dir "$0"

# Run the Python script using uv
cd "$SCRIPT_DIR/crawler" && uv run python crawler.py "$@"
7 changes: 4 additions & 3 deletions directory-concat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
# @raycast.author Nick Trombley
# @raycast.authorURL https://github.com/Aias

# Load zsh environment
source ~/.zshrc
# Load shell configuration
source "$(dirname "$0")/scripts/common.sh"
load_shell_config

# Get the directory where this script is located
SCRIPT_DIR="${0:a:h}"
set_script_dir "$0"

# Run the actual script
exec "$SCRIPT_DIR/directory-concat/directory-concat.sh" "$@"
7 changes: 4 additions & 3 deletions extract-tweet-media.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
# @raycast.author Nick Trombley
# @raycast.authorURL https://github.com/Aias

# Load zsh environment (includes homebrew, python, etc)
source ~/.zshrc
# Load shell configuration (includes homebrew, python, etc)
source "$(dirname "$0")/scripts/common.sh"
load_shell_config

# Get the directory where this script is located
SCRIPT_DIR="${0:a:h}"
set_script_dir "$0"

# Run the actual script
exec "$SCRIPT_DIR/extract-tweet-media/extract-tweet-media.sh" "$@"
7 changes: 4 additions & 3 deletions finder-to-ghostty.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
# @raycast.author Nick Trombley
# @raycast.authorURL https://github.com/Aias

# Load zsh environment
source ~/.zshrc
# Load shell configuration
source "$(dirname "$0")/scripts/common.sh"
load_shell_config

# Get the directory where this script is located
SCRIPT_DIR="${0:a:h}"
set_script_dir "$0"

# Run the actual script
exec "$SCRIPT_DIR/finder-to-ghostty/finder-to-ghostty.sh" "$@"
7 changes: 4 additions & 3 deletions flatten-opml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
# @raycast.author Nick Trombley
# @raycast.authorURL https://github.com/Aias

# Load zsh environment
source ~/.zshrc
# Load shell configuration
source "$(dirname "$0")/scripts/common.sh"
load_shell_config

# Get the directory where this script is located
SCRIPT_DIR="${0:a:h}"
set_script_dir "$0"

# Run the Python script using uv
cd "$SCRIPT_DIR/flatten_opml" && uv run python flatten_opml.py "$@"
7 changes: 4 additions & 3 deletions read-later-to-html.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
# @raycast.author Nick Trombley
# @raycast.authorURL https://github.com/Aias

# Load zsh environment
source ~/.zshrc
# Load shell configuration
source "$(dirname "$0")/scripts/common.sh"
load_shell_config

# Get the directory where this script is located
SCRIPT_DIR="${0:a:h}"
set_script_dir "$0"

# Run the Python script using uv
cd "$SCRIPT_DIR/read-later-to-html" && uv run python read-later-to-html.py "$@"
22 changes: 22 additions & 0 deletions scripts/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Common utility functions for Raycast wrappers

# Load either ~/.zshrc or ~/.bashrc so that environment variables are available
load_shell_config() {
if [ -f "$HOME/.zshrc" ]; then
# shellcheck source=/dev/null
. "$HOME/.zshrc"
elif [ -f "$HOME/.bashrc" ]; then
# shellcheck source=/dev/null
. "$HOME/.bashrc"
else
echo "Warning: No shell configuration file found (expected ~/.zshrc or ~/.bashrc)" >&2
fi
}

# Set SCRIPT_DIR to the absolute directory of the provided script path
# $1 - path to the calling script (usually "$0")
set_script_dir() {
local script_path="$1"
SCRIPT_DIR="$(dirname "$(realpath "$script_path")")"
}

7 changes: 4 additions & 3 deletions sort-opml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
# @raycast.author Nick Trombley
# @raycast.authorURL https://github.com/Aias

# Load zsh environment
source ~/.zshrc
# Load shell configuration
source "$(dirname "$0")/scripts/common.sh"
load_shell_config

# Get the directory where this script is located
SCRIPT_DIR="${0:a:h}"
set_script_dir "$0"

# Run the Python script using uv
cd "$SCRIPT_DIR/sort_opml" && uv run python sort_opml.py "$@"
7 changes: 4 additions & 3 deletions summarize-transcript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
# @raycast.author Nick Trombley
# @raycast.description Summarize an existing transcript using OpenAI

# Load zsh environment (includes environment variables)
source ~/.zshrc
# Load shell configuration (includes environment variables)
source "$(dirname "$0")/scripts/common.sh"
load_shell_config

# Get the directory where this script is located
SCRIPT_DIR="${0:a:h}"
set_script_dir "$0"

# Run the Bun/TypeScript summarizer
bun "$SCRIPT_DIR/audio-transcriber/summarize-only.ts" "$@"
7 changes: 4 additions & 3 deletions transcribe-audio-only.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
# @raycast.author Nick Trombley
# @raycast.description Transcribe audio files using AssemblyAI (no cleaning or summarization)

# Load zsh environment (includes environment variables)
source ~/.zshrc
# Load shell configuration (includes environment variables)
source "$(dirname "$0")/scripts/common.sh"
load_shell_config

# Get the directory where this script is located
SCRIPT_DIR="${0:a:h}"
set_script_dir "$0"

# Run the Bun/TypeScript transcriber
bun "$SCRIPT_DIR/audio-transcriber/transcribe-only.ts" "$@"
7 changes: 4 additions & 3 deletions transcribe-audio.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
# @raycast.author Nick Trombley
# @raycast.description Transcribe and summarize audio files using Deepgram and OpenAI

# Load zsh environment (includes environment variables)
source ~/.zshrc
# Load shell configuration (includes environment variables)
source "$(dirname "$0")/scripts/common.sh"
load_shell_config

# Get the directory where this script is located
SCRIPT_DIR="${0:a:h}"
set_script_dir "$0"

# Run the Bun/TypeScript transcriber
bun "$SCRIPT_DIR/audio-transcriber/index.ts" "$@"