Default gems, better brew install, and Pry configuration

This commit is contained in:
Michael Yockey
2023-01-25 16:53:25 -05:00
parent 1737a0f0a8
commit 701b115ca3
7 changed files with 41 additions and 42 deletions

View File

@@ -1,66 +1,48 @@
#!/bin/zsh
function zsh_check_installed() {
function git_check_installed() {
ls . | grep $1 > /dev/null
result=$?
return $result
}
function brew_check_installed() {
brew info $1 | grep "Not installed" > /dev/null
result=$?
((result ^= 1))
return $result
}
INSTALL_DIR=$HOME/.files
mkdir -p packages
pushd packages
# Install ZSH packages
which git > /dev/null
if (( $? == 0 )); then
while IFS= read -r line; do
directory=${${line%.git}#*/}
zsh_check_installed $directory
if [[ $? != 0 ]]; then
echo "Cloning $line into packages..."
git clone -q $line
else
echo "$directory already installed"
fi
done < ../dependencies/zsh.txt
else
echo "Install git before continuing"
exit 1
fi
which brew > /dev/null
if (( $? == 0 )); then
# Install Homebrew packages
while IFS= read -r line; do
brew_check_installed $line
if [[ $? != 0 ]]; then
echo "Installing $line with Homebrew"
brew install $line
else
echo "$line already installed"
fi
done < ../dependencies/homebrew.txt
brew install -q $(< ./dependencies/homebrew.txt)
else
echo "Install homebrew before continuing"
exit 1
fi
mkdir -p packages
pushd packages
while IFS= read -r line; do
directory=${${line%.git}#*/}
git_check_installed $directory
if [[ $? != 0 ]]; then
echo "Cloning $line into packages..."
git clone -q $line
else
echo "$directory already installed"
fi
done < ../dependencies/git.txt
popd
# Post-install
mkdir -p $INSTALL_DIR
cp -rf packages $INSTALL_DIR/packages
cp -rf packages $INSTALL_DIR/
cp -f zshrc $INSTALL_DIR/zshrc
cp -rf functions $INSTALL_DIR/functions
cp -f env $INSTALL_DIR/.env
cp -f pryrc $INSTALL_DIR/.pryrc
mkdir -p $(rbenv root)/plugins
ln -sf $INSTALL_DIR/packages/rbenv-default-gems $(rbenv root)/plugins/rbenv-default-gems
ln -sf $INSTALL_DIR/dependencies/gems.txt $(rbenv root)/default-gems
# Insert the INSTALL_DIR variable into the installed run control file
sed -i "" -e "1 i\\
@@ -68,3 +50,4 @@ INSTALL_DIR=$INSTALL_DIR\\
" $INSTALL_DIR/zshrc
ln -sf $INSTALL_DIR/zshrc ~/.zshrc
ln -sf $INSTALL_DIR/.pryrc ~/.pryrc