2024-02-12 01:07:09 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-02-16 19:48:23 +00:00
|
|
|
# Installs poetry-based python dependencies
|
|
|
|
echo "Installing python dependencies"
|
|
|
|
poetry install
|
2024-02-12 01:07:09 +00:00
|
|
|
|
2024-02-16 19:35:48 +00:00
|
|
|
# List of commands to check and add or update alias for
|
2024-02-12 01:07:09 +00:00
|
|
|
commands=("fabric" "fabric-api" "fabric-webui")
|
|
|
|
|
|
|
|
# List of shell configuration files to update
|
|
|
|
config_files=(~/.bashrc ~/.zshrc)
|
|
|
|
|
|
|
|
for config_file in "${config_files[@]}"; do
|
|
|
|
# Check if the configuration file exists
|
|
|
|
if [ -f "$config_file" ]; then
|
|
|
|
echo "Updating $config_file"
|
|
|
|
for cmd in "${commands[@]}"; do
|
|
|
|
# Get the path of the command
|
|
|
|
CMD_PATH=$(poetry run which $cmd)
|
|
|
|
|
|
|
|
# Check if the config file contains an alias for the command
|
|
|
|
if grep -q "alias $cmd=" "$config_file"; then
|
2024-02-16 19:35:48 +00:00
|
|
|
# Replace the existing alias with the new one
|
|
|
|
sed -i "/alias $cmd=/c\alias $cmd='$CMD_PATH'" "$config_file"
|
|
|
|
echo "Updated alias for $cmd in $config_file."
|
2024-02-12 01:07:09 +00:00
|
|
|
else
|
|
|
|
# If not, add the alias to the config file
|
|
|
|
echo "alias $cmd='$CMD_PATH'" >> "$config_file"
|
2024-02-16 19:35:48 +00:00
|
|
|
echo "Added alias for $cmd to $config_file."
|
2024-02-12 01:07:09 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
else
|
|
|
|
echo "$config_file does not exist."
|
|
|
|
fi
|
2024-02-16 20:11:30 +00:00
|
|
|
done
|
|
|
|
|
2024-02-16 20:20:24 +00:00
|
|
|
echo "Please close this terminal window to have new aliases work."
|