68 lines
1.7 KiB
Bash
Executable file
68 lines
1.7 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# Set the script directory and project root directory
|
|
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
cd "$script_dir" || exit 1
|
|
project_root=$(git rev-parse --show-toplevel)
|
|
|
|
# Function to install packwiz and add it to the system path
|
|
install_packwiz() {
|
|
# Download packwiz executable
|
|
wget https://seafsh.cc/u/O5JTlL -O packwiz
|
|
|
|
# Move packwiz executable to a system directory (you may need sudo)
|
|
sudo mv packwiz /usr/local/bin/packwiz
|
|
sudo chmod +x /usr/local/bin/packwiz
|
|
sudo chmod 111 /usr/local/bin/packwiz
|
|
|
|
# Add packwiz to the system path
|
|
if [[ ! ":$PATH:" == *":/usr/local/bin:"* ]]; then
|
|
echo "export PATH='$PATH:/usr/local/bin'" >>~/.bashrc
|
|
fi
|
|
|
|
# Generate autocompletion script
|
|
packwiz completion bash >~/.packwiz
|
|
if ! grep -q "source ~/.packwiz" ~/.bashrc; then
|
|
echo 'source ~/.packwiz' >>~/.bashrc
|
|
echo "Successfully enabled packwiz autocompletion"
|
|
else
|
|
echo "packwiz autocompletion already enabled"
|
|
fi
|
|
|
|
source ~/.bashrc
|
|
}
|
|
|
|
# Function to create symlink for pre-commit hook
|
|
create_symlink() {
|
|
# Check if .git/hooks directory exists
|
|
if [ ! -d "$project_root/.git/hooks" ]; then
|
|
mkdir -p "$project_root/.git/hooks"
|
|
fi
|
|
|
|
# Delete old symlink
|
|
rm -f "$project_root/.git/hooks/post-commit"
|
|
|
|
# Create symlink for post-commit hook
|
|
ln -s "$project_root/scripts/hooks/post-commit" "$project_root/.git/hooks/post-commit"
|
|
|
|
# Verify symlink creation
|
|
ls -l "$project_root/.git/hooks/post-commit"
|
|
}
|
|
|
|
# Main function
|
|
main() {
|
|
# Install packwiz
|
|
if ! which packwiz &>/dev/null; then
|
|
install_packwiz
|
|
else
|
|
echo "packwiz is already installed, skipping installation step"
|
|
fi
|
|
|
|
# Create symlink for pre-commit hook
|
|
create_symlink
|
|
|
|
echo "Development environment setup complete!"
|
|
}
|
|
|
|
# Execute main function
|
|
main
|