Files
easyzsh/install_merlin_worker.sh

51 lines
1.7 KiB
Bash

#!/bin/bash
# Exit on any error
set -e
# Download and execute the patch script
if ! curl -s https://git.miomio.moe/mio/easyzsh/raw/branch/master/patch.sh | bash -s merlin_worker; then
echo "Error: Failed to download or execute patch script"
exit 1
fi
# Check if ~/.bashrc exists and contains PYTHONPATH export
if [ -f "$HOME/.bashrc" ]; then
# Extract PYTHONPATH from ~/.bashrc (look for export PYTHONPATH=...)
BASHRC_PYTHONPATH=$(grep -E "^export PYTHONPATH=" "$HOME/.bashrc" | tail -1)
if [ -n "$BASHRC_PYTHONPATH" ]; then
echo "Found PYTHONPATH in ~/.bashrc: $BASHRC_PYTHONPATH"
# Path to the merlin_worker.zsh file
MERLIN_CONFIG="$HOME/.config/zshrc/merlin_worker.zsh"
# Create directory if it doesn't exist
mkdir -p "$(dirname "$MERLIN_CONFIG")"
if [ -f "$MERLIN_CONFIG" ]; then
# Cross-platform sed: remove existing PYTHONPATH lines
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
sed -i '' '/^export PYTHONPATH=/d' "$MERLIN_CONFIG"
else
# Linux/Ubuntu and others
sed -i '/^export PYTHONPATH=/d' "$MERLIN_CONFIG"
fi
# Then append the PYTHONPATH from ~/.bashrc
echo "$BASHRC_PYTHONPATH" >> "$MERLIN_CONFIG"
echo "Updated PYTHONPATH in $MERLIN_CONFIG with value from ~/.bashrc"
else
# Create the file with just the PYTHONPATH
echo "$BASHRC_PYTHONPATH" > "$MERLIN_CONFIG"
echo "Created $MERLIN_CONFIG with PYTHONPATH from ~/.bashrc"
fi
else
echo "No PYTHONPATH export found in ~/.bashrc"
fi
else
echo "~/.bashrc not found"
fi