Bash tools setup
- Ensure that your tools are installed with Bash
- Updating a repository with Bash
- Automating Jupyter & Jupyter kernel installation
checkTool() {
echo "Checking if $1 is installed..."
# evaluate check command and check its exit code
if eval "$2"; then
echo "Success! $1 is installed."
else
echo "Error: $1 is not installed properly!"
fi
echo
}
checkKernel() {
echo "Checking if the $1 Jupyter kernel is installed..."
# check if kernel is listed in current kernelspec
if jupyter kernelspec list | grep --color=never "$1"; then
echo "Success! the $1 Jupyter kernel is installed."
else
echo "Error: the $1 Jupyter kernel is not installed properly!"
fi
echo
}
checkTool "conda" "conda --version"
checkTool "jupyter" "conda list | grep jupyter | head -n 1"
checkKernel "bash"
checkKernel "javascript"
checkKernel "python"
# change into a git-initialized directory
cd /home/user/projects/apcsp || exit
# pull from remote
git pull
# stage files for comitting
git add .
# commit with a message
git commit -m "feat: added stuff"
# push changes to remote origin on branch master
git push origin master
failedto() {
echo "Failed to $1. Please manually debug any errors printed to STDERR."
exit
}
if ! jupyter &>/dev/null; then
failedto "ensure that Jupyter was installed"
fi
{
echo "Installing Jupyter bash kernel..."
pip install bash_kernel
python -m bash_kernel.install
} || failedto "install bash kernel"
{
echo "Installing Jupyter node kernel..."
npm install --global ijavascript
ijsinstall
} || failedto "install node kernel"
echo "Both the bash and javascript (via NodeJS) kernels have been installed!"