Skip to content

Instantly share code, notes, and snippets.

@DrBluefall
Created July 19, 2019 02:28
Show Gist options
  • Save DrBluefall/e712446b2b461d2ca4e861e547d25748 to your computer and use it in GitHub Desktop.
Save DrBluefall/e712446b2b461d2ca4e861e547d25748 to your computer and use it in GitHub Desktop.
edit(){
if [ $1 = "prisbot" ];
then
cd /Users/prismarine/Desktop/projects/ProjectPrismarine
echo "edit: Fetching latest changes..."
git pull --all >/dev/null 2&>1
if [ $? = 1 ];
then
echo -e "edit: \e[38;5;196mERROR\e[0m - \e[38;5;196mRepository fetch failed\e[0m, your current repository version of $(zsh_git_link) may be out of date."
else
echo -e "edit: \e[38;5;46mRepository updated!\e[0m"
fi
if [ $# -eq 2 ];
then
echo "edit: Checking out to $2..."
git checkout $2 >/dev/null 2&>1
if [ $? != 0 ];
then
echo -e "edit: \e[38;5;226mWARNING - Invalid branch specifed.\e[0m Defaulting to master."
git checkout master >/dev/null 2&>1
else
echo "edit: \e[38;5;46mSuccesfully checked out to branch $2!\e[0m"
fi
else
echo "edit: Checking out to master..."
git checkout master >/dev/null 2&>1
echo "edit: Successfully checked out to master!"
fi
echo "edit: Activating Virtual Environment..."
source .venv/bin/activate
if [ $? != 0 ];
then
echo -e "edit: \e[38;5;196mERROR - Issue when attempting to startup virtual environment. Halting process."
return
else
echo -e "edit: \e[38;5;46mVirtual Environment activated!\e[0m"
fi
echo "edit: Installing dependencies..."
pip install -r requirements.txt >/dev/null 2&>1
if [ $? != 0 ];
then
echo -e "edit: \e[38;5;196mERROR - Issue when attempting to install dependencies. Halting process."
return
else
echo -e "edit: \e[38;5;46mAll dependencies up to date!\e[0m"
fi
echo "edit: \e[38;5;84mOpening Visual Studio Code...\e[0m"
vscode /Users/prismarine/Desktop/Projects/ProjectPrismarine
echo -e "edit: \e[38;5;46mWorkspace setup complete!\e[0m"
elif [ $1 = "otd" ];
then
cd /Users/prismarine/Desktop/projects/offthedialbot
source .venv/bin/activate
echo "edit: Fetching latest changes..."
git pull --all >/dev/null 2&>1
if [ $? = 1 ];
then
echo -e "edit: \e[38;5;196mERROR\e[0m - \e[38;5;196mRepository fetch failed\e[0m, your current repository version of $(zsh_git_link) may be out of date."
else
echo -e "edit: \e[38;5;46mRepository updated!\e[0m"
fi
if [ $# -eq 2 ];
then
echo "edit: Checking out to $2..."
git checkout $2 >/dev/null 2&>1
if [ $? != 0 ];
then
echo -e "edit: \e[38;5;226mWARNING - Invalid branch specifed.\e[0m Defaulting to master."
git checkout master >/dev/null 2&>1
else
echo "edit: \e[38;5;46mSuccesfully checked out to branch $2!\e[0m"
fi
else
echo "edit: Checking out to master..."
git checkout master >/dev/null 2&>1
echo "edit: Successfully checked out to master!"
fi
echo "edit: Activating Virtual Environment..."
source .venv/bin/activate
if [ $? != 0 ];
then
echo -e "edit: \e[38;5;196mERROR - Issue when attempting to startup virtual environment. Halting process."
return
else
echo -e "edit: \e[38;5;46mVirtual Environment activated!\e[0m"
fi
echo "edit: Installing dependencies..."
pip install -r requirements.txt >/dev/null 2&>1
if [ $? != 0 ];
then
echo -e "edit: \e[38;5;196mERROR - Issue when attempting to install dependencies. Halting process."
return
else
echo -e "edit: \e[38;5;46mAll dependencies up to date!\e[0m"
fi
echo "edit: \e[38;5;84mOpening Visual Studio Code...\e[0m"
vscode /Users/prismarine/Desktop/projects/offthedialbot
echo -e "edit: \e[38;5;46mWorkspace setup complete!\e[0m"
elif [ $1 = ".zshrc" ];
then
cd ~
vscode .zshrc
else
echo -n "edit: \e[38;5;196mInvalid Project\e[0m: $1"
return 1
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment