diff --git a/.gitignore b/.gitignore index 80d1be7..e43b0f9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1 @@ -packages -env -.DS_Store \ No newline at end of file +.DS_Store diff --git a/dependencies/git.txt b/dependencies/git.txt deleted file mode 100644 index 5e138ba..0000000 --- a/dependencies/git.txt +++ /dev/null @@ -1,2 +0,0 @@ -git@github.com:geometry-zsh/geometry.git -git@github.com:rbenv/rbenv-default-gems.git diff --git a/dependencies/homebrew.txt b/dependencies/homebrew.txt index a11f9d7..b8131c7 100644 --- a/dependencies/homebrew.txt +++ b/dependencies/homebrew.txt @@ -1,9 +1,12 @@ +fzf git +gnupg +nodenv +pinentry-mac +rbenv +ruby-build +stow +zoxide zsh zsh-completions zsh-autosuggestions -rbenv -ruby-build -nodenv -gnupg -pinentry-mac diff --git a/install.zsh b/install.zsh index 7a6971e..4b1bb15 100755 --- a/install.zsh +++ b/install.zsh @@ -1,54 +1,25 @@ #!/bin/zsh -function git_check_installed() { - ls . | grep $1 > /dev/null - result=$? - return $result -} - -INSTALL_DIR=$HOME/.files - which brew > /dev/null -if (( $? == 0 )); then - brew install -q $(< ./dependencies/homebrew.txt) -else - echo "Install homebrew before continuing" - exit 1 +if (( $? != 0 )); then + echo "First installing Homebrew" + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 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 +echo "Installing dependencies from Homebrew" +brew install -q $(< ./dependencies/homebrew.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 -# Post-install -touch ./env -mkdir -p $INSTALL_DIR -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 +echo "Installing Zsh plugins" +pushd zsh/dot-scripts +git -C geometry pull || git clone git@github.com:geometry-zsh/geometry.git geometry +popd -# 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 -ln -sf $INSTALL_DIR/.pryrc ~/.pryrc +echo "Linking files" +stow --dotfiles -t ~ zsh +stow --dotfiles -t ~ ruby diff --git a/dependencies/gems.txt b/ruby/.rbenv/default-gems similarity index 100% rename from dependencies/gems.txt rename to ruby/.rbenv/default-gems diff --git a/ruby/.rbenv/plugins/.gitignore b/ruby/.rbenv/plugins/.gitignore new file mode 100644 index 0000000..475f083 --- /dev/null +++ b/ruby/.rbenv/plugins/.gitignore @@ -0,0 +1 @@ +rbenv-default-gems diff --git a/pryrc b/ruby/dot-pryrc similarity index 52% rename from pryrc rename to ruby/dot-pryrc index 0c6170c..3dcb444 100644 --- a/pryrc +++ b/ruby/dot-pryrc @@ -15,4 +15,29 @@ else Pry.print = proc { |output, value| output.puts value.ai({ limit: true }) } puts 'AwesomePrint available in this session' 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 diff --git a/zsh/.gitignore b/zsh/.gitignore new file mode 100644 index 0000000..e256a05 --- /dev/null +++ b/zsh/.gitignore @@ -0,0 +1 @@ +dot-env diff --git a/functions/wreck.zsh b/zsh/dot-functions/wreck.zsh similarity index 100% rename from functions/wreck.zsh rename to zsh/dot-functions/wreck.zsh diff --git a/zsh/dot-scripts/.gitignore b/zsh/dot-scripts/.gitignore new file mode 100644 index 0000000..07ee6e8 --- /dev/null +++ b/zsh/dot-scripts/.gitignore @@ -0,0 +1 @@ +geometry diff --git a/zshrc b/zsh/dot-zshrc similarity index 80% rename from zshrc rename to zsh/dot-zshrc index 866aca1..0ba32e7 100644 --- a/zshrc +++ b/zsh/dot-zshrc @@ -1,11 +1,8 @@ +source ~/.env + eval "$(rbenv init -)" eval "$(nodenv init -)" - -while IFS= read -r line; do - export $line -done <$INSTALL_DIR/.env - -source $INSTALL_DIR/packages/geometry/geometry.zsh +eval "$(zoxide init --cmd cd zsh)" if type brew &>/dev/null; then FPATH=$(brew --prefix)/share/zsh/site-functions:$FPATH @@ -16,11 +13,7 @@ fi source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh # 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; - -for file in $INSTALL_DIR/functions/*.zsh; do - source $file -done +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 typeset -U path cdpath fpath setopt auto_cd @@ -34,5 +27,9 @@ export TERM="xterm-256color" export GPG_TTY=$(tty) export EDITOR="code -nw" export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)" - export PATH="/usr/local/sbin:$PATH" + +for file in $HOME/.functions/*.zsh; do + source $file +done +source $HOME/.scripts/geometry/geometry.zsh