This is a bash script that installs another bash script as a command in your ~/.zshrc file. This is a script I use to install this script to quickly bootstrap a FastAPI project. In the code below, replace create-fast-app with the command name you prefer.

#!/bin/bash

# check if the user provided a script name as an argument
if [ -z "$1" ]; then
  echo "Please provide a script name as an argument."
  exit 1
fi

# get the path to the provided script
script_path=$1

# check if the provided script exists
if [ ! -f "$script_path" ]; then
  echo "The provided script does not exist."
  exit 1
fi

# check if the user has a ~/.zshrc file
if [ ! -f ~/.zshrc ]; then
  echo "You do not have a ~/.zshrc file. Creating one..."
  touch ~/.zshrc
fi

# add an alias to the provided script in the user's ~/.zshrc file
echo "alias create-fast-app='$script_path'" >> ~/.zshrc

echo "Successfully added an alias to the provided script in your ~/.zshrc file."

To use this script, save it to a file (e.g. install-script.sh) and make it executable with the following command:

chmod +x install-script.sh

Then, you can run it with the path to the script you want to install as an argument, like this:

./install-script.sh /path/to/script.sh

This will add an alias to the provided script in your ~/.zshrc file, allowing you to invoke it with the create-fast-app command.

Note: This script assumes that you are using the zsh shell. If you are using a different shell you may need to tweak this for your own setup.

Now I can bootstrap a new FastAPI project like this in 5 seconds! What is the world coming to?

Quickly Set Up a FastAPI App with This Script