Replace custom package management with Gnu Stow support

This commit is contained in:
Michael Yockey
2024-02-17 19:50:05 -05:00
parent 7cbb4be5b9
commit e793368e27
11 changed files with 62 additions and 67 deletions

2
.gitignore vendored
View File

@@ -1,3 +1 @@
packages
env
.DS_Store .DS_Store

View File

@@ -1,2 +0,0 @@
git@github.com:geometry-zsh/geometry.git
git@github.com:rbenv/rbenv-default-gems.git

View File

@@ -1,9 +1,12 @@
fzf
git git
gnupg
nodenv
pinentry-mac
rbenv
ruby-build
stow
zoxide
zsh zsh
zsh-completions zsh-completions
zsh-autosuggestions zsh-autosuggestions
rbenv
ruby-build
nodenv
gnupg
pinentry-mac

View File

@@ -1,54 +1,25 @@
#!/bin/zsh #!/bin/zsh
function git_check_installed() {
ls . | grep $1 > /dev/null
result=$?
return $result
}
INSTALL_DIR=$HOME/.files
which brew > /dev/null which brew > /dev/null
if (( $? == 0 )); then if (( $? != 0 )); then
brew install -q $(< ./dependencies/homebrew.txt) echo "First installing Homebrew"
else /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo "Install homebrew before continuing"
exit 1
fi fi
mkdir -p packages echo "Installing dependencies from Homebrew"
pushd packages brew install -q $(< ./dependencies/homebrew.txt)
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
echo "Installing rbenv plugins"
pushd ruby/.rbenv/plugins
git -C rbenv-default-gems pull || git clone git@github.com:rbenv/rbenv-default-gems.git rbenv-default-gems
popd popd
# Post-install echo "Installing Zsh plugins"
touch ./env pushd zsh/dot-scripts
mkdir -p $INSTALL_DIR git -C geometry pull || git clone git@github.com:geometry-zsh/geometry.git geometry
cp -rf packages $INSTALL_DIR/ popd
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\\
INSTALL_DIR=$INSTALL_DIR\\
" $INSTALL_DIR/zshrc
ln -sf $INSTALL_DIR/zshrc ~/.zshrc echo "Linking files"
ln -sf $INSTALL_DIR/.pryrc ~/.pryrc stow --dotfiles -t ~ zsh
stow --dotfiles -t ~ ruby

1
ruby/.rbenv/plugins/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
rbenv-default-gems

View File

@@ -15,4 +15,29 @@ else
Pry.print = proc { |output, value| output.puts value.ai({ limit: true }) } Pry.print = proc { |output, value| output.puts value.ai({ limit: true }) }
puts 'AwesomePrint available in this session' puts 'AwesomePrint available in this session'
end end
Pry.config.editor = proc { |file, line| "code --wait --goto #{file}:#{line} --disable-workspace-trust" } Pry.config.editor = proc { |file, line| "nvim +'#{line}|norm! zt' file" }
# Pry::Commands.create_command 'benchmark' do
# description <<~DESCRIPTION
# Benchmark a block of code. The block is executed 100 times and the average
# time is displayed. The result of the block is also returned.
#
# Usage: benchmark do
# # code to benchmark
# end
# DESCRIPTION
#
# banner <<~BANNER
# Usage: benchmark do
# # code to benchmark
# end
# BANNER
#
# command_options takes_block: true
#
# def process
# start = Time.now
# command_block
# output.puts "Time elapsed #{Time.now - start} seconds"
# end
# end

1
zsh/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
dot-env

1
zsh/dot-scripts/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
geometry

View File

@@ -1,11 +1,8 @@
source ~/.env
eval "$(rbenv init -)" eval "$(rbenv init -)"
eval "$(nodenv init -)" eval "$(nodenv init -)"
eval "$(zoxide init --cmd cd zsh)"
while IFS= read -r line; do
export $line
done <$INSTALL_DIR/.env
source $INSTALL_DIR/packages/geometry/geometry.zsh
if type brew &>/dev/null; then if type brew &>/dev/null; then
FPATH=$(brew --prefix)/share/zsh/site-functions:$FPATH FPATH=$(brew --prefix)/share/zsh/site-functions:$FPATH
@@ -16,11 +13,7 @@ fi
source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh
# heroku autocomplete setup # heroku autocomplete setup
HEROKU_AC_ZSH_SETUP_PATH=/Users/myockey/Library/Caches/heroku/autocomplete/zsh_setup && test -f $HEROKU_AC_ZSH_SETUP_PATH && source $HEROKU_AC_ZSH_SETUP_PATH; HEROKU_AC_ZSH_SETUP_PATH=/Users/myockey/Library/Caches/heroku/autocomplete/zsh_setup && test -f $HEROKU_AC_ZSH_SETUP_PATH && source $HEROKU_AC_ZSH_SETUP_PATH
for file in $INSTALL_DIR/functions/*.zsh; do
source $file
done
typeset -U path cdpath fpath typeset -U path cdpath fpath
setopt auto_cd setopt auto_cd
@@ -34,5 +27,9 @@ export TERM="xterm-256color"
export GPG_TTY=$(tty) export GPG_TTY=$(tty)
export EDITOR="code -nw" export EDITOR="code -nw"
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)" export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)"
export PATH="/usr/local/sbin:$PATH" export PATH="/usr/local/sbin:$PATH"
for file in $HOME/.functions/*.zsh; do
source $file
done
source $HOME/.scripts/geometry/geometry.zsh