From 1e43546b9a6d0b1b9cb4ecac7030c642cbd3ff38 Mon Sep 17 00:00:00 2001 From: Stefan Imhoff Date: Thu, 27 Oct 2022 19:53:56 +0200 Subject: [PATCH] Add asdf as version manager (#2) * feat(asdf): add new version manager asdf * feat(asdf): replace nvm with asdf * feat(asdf): replace rbenv with asdf * chore: add aliases for git * feat(asdf): replace pyenv with asdf * feat(asdf): add asdf as version manager for rust * chore: shorten comments * feat(asdf): add asdf as deno version manager * feat(asdf): add direnv plugin and setup shell * chore(asdf): move configuration in folder --- .dotbot.conf.yaml | 4 +++ Gemfile | 9 ++++-- asdf/asdfrc | 1 + asdf/default-gems | 6 ++++ asdf/default-npm-packages | 31 ++++++++++++++++++ asdf/default-python-packages | 3 ++ setup/deno.sh | 5 +++ setup/direnv.sh | 4 +++ setup/gem.sh | 10 ------ setup/init.sh | 29 ++++++++--------- setup/nodejs.sh | 5 +++ setup/npm.sh | 62 ------------------------------------ setup/nvm.sh | 14 -------- setup/python.sh | 17 ++-------- setup/ruby.sh | 5 +-- setup/rust.sh | 5 +-- starship.toml | 14 ++++++++ zshrc | 35 ++++---------------- 18 files changed, 107 insertions(+), 152 deletions(-) create mode 100644 asdf/asdfrc create mode 100644 asdf/default-gems create mode 100644 asdf/default-npm-packages create mode 100644 asdf/default-python-packages create mode 100755 setup/deno.sh create mode 100755 setup/direnv.sh delete mode 100755 setup/gem.sh create mode 100755 setup/nodejs.sh delete mode 100755 setup/npm.sh delete mode 100755 setup/nvm.sh diff --git a/.dotbot.conf.yaml b/.dotbot.conf.yaml index 7258622..b38dd6f 100644 --- a/.dotbot.conf.yaml +++ b/.dotbot.conf.yaml @@ -7,12 +7,16 @@ - link: ~/.ack: ack ~/.ag: ag + ~/.asdfrc: asdf/asdfrc ~/.config/base16-shell: .base16-shell ~/.config/kitty: kitty ~/.config/nvim: nvim ~/.config/starship.toml: starship.toml ~/.config/tmuxinator: tmuxinator ~/.ctags: ctags + ~/.default-gems: asdf/default-gems + ~/.default-npm-packages: asdf/default-npm-packages + ~/.default-python-packages: asdf/default-python-packages ~/.editorconfig: editorconfig ~/.gitconfig: gitconfig ~/.gitignore: gitignore diff --git a/Gemfile b/Gemfile index 6747c57..2865030 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,10 @@ source "https://rubygems.org" -gem "neovim" -gem "lunchy" -gem "git-up" +gem "bundler" gem "erb_lint" +gem "git-up" +gem "github-linguist" +gem "lunchy" +gem "neovim" +gem "tmuxinator" diff --git a/asdf/asdfrc b/asdf/asdfrc new file mode 100644 index 0000000..e600bd0 --- /dev/null +++ b/asdf/asdfrc @@ -0,0 +1 @@ +legacy_version_file = yes diff --git a/asdf/default-gems b/asdf/default-gems new file mode 100644 index 0000000..6f63b68 --- /dev/null +++ b/asdf/default-gems @@ -0,0 +1,6 @@ +bundler +erb_lint +git-up +lunchy +neovim +tmuxinator diff --git a/asdf/default-npm-packages b/asdf/default-npm-packages new file mode 100644 index 0000000..807bf94 --- /dev/null +++ b/asdf/default-npm-packages @@ -0,0 +1,31 @@ +@fsouza/prettierd +a11y +alex +babel-cli +browser-sync +caniuse-cmd +commitizen +cz-conventional-changelog +eslint +eslint_d +fast-cli +gifify +github-codeowners +json-server +jsonlint +lighthouse +markdownlint-cli +neovim +netlify-cli +npm-check +npm-check-updates +pageres-cli +pageres-cli +prettier +prettier-init +prettier-stylelint +prettier_d_slim +prettyjson +typesync +write-good +yarn diff --git a/asdf/default-python-packages b/asdf/default-python-packages new file mode 100644 index 0000000..057e310 --- /dev/null +++ b/asdf/default-python-packages @@ -0,0 +1,3 @@ +codespell +fawkes +pipenv diff --git a/setup/deno.sh b/setup/deno.sh new file mode 100755 index 0000000..e4fbfbd --- /dev/null +++ b/setup/deno.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +asdf plugin-add deno +asdf install deno latest +asdf global deno latest diff --git a/setup/direnv.sh b/setup/direnv.sh new file mode 100755 index 0000000..e5a2c90 --- /dev/null +++ b/setup/direnv.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +asdf plugin-add direnv +asdf direnv setup --shell zsh --version latest diff --git a/setup/gem.sh b/setup/gem.sh deleted file mode 100755 index 90189db..0000000 --- a/setup/gem.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -brew install brew-gem - -brew gem install bundler # Bundler manages an application's dependencies -brew gem install git-up # git command to fetch and rebase all branches -brew gem install github-linguist # Language Savant. -brew gem install lunchy # Friendly wrapper around launchctl -brew gem install neovim # Ruby provider for NeoVim -brew gem install erb_lint # Lint ERB or HTML diff --git a/setup/init.sh b/setup/init.sh index 487f6b7..751fe00 100755 --- a/setup/init.sh +++ b/setup/init.sh @@ -1,37 +1,34 @@ #!/bin/sh -# Install Xcode Developer Tools +# Xcode Developer Tools xcode-select --install -# Install TMUX Plugin Manager +# TMUX Plugin Manager git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm -# Install Homebrew +# Homebrew ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" -# Installing Homebrew packages, Cask binaries and Mac App Store software +# Homebrew packages, Cask binaries and Mac App Store software source ./brew.sh -# Installing Node.js -source ./nvm.sh +# Direnv +source ./direnv.sh -# Installing global Node.js modules -source ./npm.sh +# Node.js +source ./nodejs.sh -# Installing Python version manager +# Python source ./python.sh -# Installing Lua packages +# Lua source ./lua.sh -# Installing Rust packages +# Rust source ./rust.sh -# Install current version of Ruby +# Ruby source ./ruby.sh -# Install global Gems -source ./gem.sh - -# Install Visual Studio Code Extensions +# Visual Studio Code Extensions source ./vscode.sh diff --git a/setup/nodejs.sh b/setup/nodejs.sh new file mode 100755 index 0000000..a52e58d --- /dev/null +++ b/setup/nodejs.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +asdf plugin-add nodejs +asdf install nodejs latest +asdf global nodejs latest diff --git a/setup/npm.sh b/setup/npm.sh deleted file mode 100755 index 29844ff..0000000 --- a/setup/npm.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/sh - -npm install -g @11ty/eleventy # Eleventy -npm install -g @hyperspace/cli # Hyp CLI -npm install -g @fsouza/prettierd # Prettier, as a daemon, for ludicrous formatting speed -npm install -g a11y # Runs an accessibility audit against a URL -npm install -g alex # Catch insensitive, inconsiderate writing -npm install -g babel-cli # Babel command line -npm install -g browser-sync # Live CSS Reload & Browser Syncing -npm install -g caniuse-cmd # caniuse for the command line ➜ caniuse border-radius -npm install -g commitizen # Git commit, but play nice with conventions ➜ git cz -npm install -g cz-conventional-changelog # Prompts for conventional changelog standard -npm install -g degit # Straightforward project scaffolding -npm install -g esbuild # An extremely fast JavaScript bundler -npm install -g eslint # An AST-based pattern checker for JavaScript -npm install -g eslint-plugin-babel -npm install -g eslint-plugin-chai -npm install -g eslint-plugin-chai-expect -npm install -g eslint-plugin-flowtype -npm install -g eslint-plugin-html -npm install -g eslint-plugin-jasmine -npm install -g eslint-plugin-jsdoc -npm install -g eslint-plugin-json -npm install -g eslint-plugin-jsx -npm install -g eslint-plugin-jsx-extras -npm install -g eslint-plugin-lodash -npm install -g eslint-plugin-mocha -npm install -g eslint-plugin-node -npm install -g eslint-plugin-react -npm install -g eslint-plugin-redux -npm install -g eslint_d # Like Eslint, but faster -npm install -g fast-cli # Test your download speed using fast.com ➜ fast -npm install -g gifify # Convert any video file to an optimized animated GIF -npm install -g github-codeowners # A CLI tool for working with GitHub CODEOWNERS -npm install -g glyphhanger # Your web font utility belt -npm install -g http-server # A simple zero-configuration command-line http server -npm install -g json-server # Small JSON file server for REST API mock ➜ touch db.json; json-server --watch db.json -npm install -g jsonlint # A JSON linter -npm install -g lighthouse # Lighthouse analyzes web apps and web pages. -npm install -g nativefier # Wrap web apps natively -npm install -g neovim # Node.js provider for NeoVim -npm install -g netlify-cli # The Netlify CLI tools. -npm install -g nodemon # Simple monitor script for use during development of a node.js app. -npm install -g npm-check # Check for outdated, incorrect, and unused dependencies. ➜ npm-check -g -npm install -g npm-check-updates # Find newer versions of dependencies ➜ ncu -npm install -g npx # Executes commands -npm install -g markdownlint # Markdown lint tool and style checker -npm install -g markdownlint-cli # Command Line Interface for MarkdownLint -npm install -g pageres-cli # Capture website screenshots ➜ pageres [ todomvc.com 1200x1000 ] [ yeoman.io 800x600 1200x1000 ] --crop -npm install -g prettier # Prettier is an opinionated code formatter -npm install -g prettier-init # Just a CLI for creating a .prettierrc file. -npm install -g prettier-stylelint # Format your styles with ease -npm install -g prettier_d_slim # Prettier, but fast -npm install -g prettyjson # Package for formatting JSON data ➜ prettyjson package.json. curl https://api.github.com/users/rafeca | prettyjson -npm install -g stylelint # Modern CSS linter -npm install -g stylelint-config-prettier -npm install -g stylelint-config-standard -npm install -g tldr # tldr; -npm install -g typescript # TypeScript is a language for application scale JavaScript development -npm install -g typesync # Install missing TypeScript typings for dependencies in your package.json. -npm install -g write-good # Linter for English prose -npm install -g yarn # Fast, reliable, and secure dependency management. diff --git a/setup/nvm.sh b/setup/nvm.sh deleted file mode 100755 index d81c58b..0000000 --- a/setup/nvm.sh +++ /dev/null @@ -1,14 +0,0 @@ - #!/bin/sh - - # Manual install of nvm -git clone https://github.com/creationix/nvm.git ~/.nvm -cd ~/.nvm -git checkout `git describe --abbrev=0 --tags` -cd ~/.dotfiles/ - -# Reload nvm into this environment -export NVM_DIR="$HOME/.nvm/" -[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm - -nvm install stable -nvm alias default stable diff --git a/setup/python.sh b/setup/python.sh index 90c8e2b..69e9069 100755 --- a/setup/python.sh +++ b/setup/python.sh @@ -1,21 +1,10 @@ #!/bin/sh -# Install Pyenv -curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash - -# Activate Pyenv -export PYENV_ROOT="$HOME/.pyenv" -export PATH="$PYENV_ROOT/bin:$PATH" -eval "$(pyenv init --path)" -eval "$(pyenv virtualenv-init -)" - -pyenv install 3.10.1 +asdf plugin-add python +asdf install python latest +asdf global python latest pip install -r ~/.dotfiles/python/pip-requirements.txt -jupyter nbextension install --py --sys-prefix jupyter_ascending -jupyter nbextension enable jupyter_ascending --sys-prefix --py -jupyter serverextension enable jupyter_ascending --sys-prefix --py - conda install -n base ipykernel --update-deps --force-reinstall conda install --file ~/.dotfiles/python/conda-requirements.txt diff --git a/setup/ruby.sh b/setup/ruby.sh index 5c41a32..5e43ea2 100755 --- a/setup/ruby.sh +++ b/setup/ruby.sh @@ -1,6 +1,7 @@ #!/bin/sh -rbenv install $(rbenv install -l | grep -v - | tail -1) -rbenv global $(rbenv install -l | grep -v - | tail -1) +asdf plugin add ruby +asdf install ruby latest +asdf global ruby latest bundle install --gemfile=~/.dotfiles/Gemfile diff --git a/setup/rust.sh b/setup/rust.sh index 791c86a..410c124 100755 --- a/setup/rust.sh +++ b/setup/rust.sh @@ -1,6 +1,7 @@ #!/bin/sh -# Install Rust -curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh +asdf plugin-add rust +asdf install rust latest +asdf global rust latest cargo install stylua diff --git a/starship.toml b/starship.toml index c847d71..c989f97 100644 --- a/starship.toml +++ b/starship.toml @@ -1,6 +1,20 @@ # Don't print a new line at the start of the prompt add_newline = false +command_timeout = 1000 + +[nodejs] +detect_files = ["package.json", ".node-version", ".nvmrc", ".tool-versions"] + +[ruby] +detect_files = ["Gemfile", ".ruby-version", ".tool-versions"] + +[python] +detect_files = [".python-version", "Pipfile", "__init__.py", "pyproject.toml", "requirements.txt", "setup.py", "tox.ini", '.tool-versions'] + +[rust] +detect_files = ["Cargo.toml", ".tool-versions"] + # "bold red" style when capacity is between 0% and 10% [[battery.display]] threshold = 10 diff --git a/zshrc b/zshrc index 84cb411..66aacc6 100644 --- a/zshrc +++ b/zshrc @@ -31,28 +31,12 @@ export FZF_CTRL_T_OPTS="--preview 'bat --color=always --style=numbers {}' --bind export FZF_ALT_C_COMMAND="fd --type d $FD_OPTIONS --color=never --hidden" export FZF_ALT_C_OPTS="--preview 'tree -C {} | head -50'" -# rbenv -export RBENV_ROOT="$HOME/.rbenv/" - -# nvm (Node Version Manager) -export NVM_DIR="$HOME/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm - # Rancher export PATH="$HOME/.rd/bin:$PATH" # Rust export PATH="$HOME/.cargo/bin:$PATH" -# Ruby -export PATH="/usr/local/opt/ruby/bin:$PATH" - -# Pyenv -export PYENV_ROOT="$HOME/.pyenv" -export PATH="$PYENV_ROOT/bin:$PATH" -eval "$(pyenv init --path)" -eval "$(pyenv virtualenv-init -)" - # Conda # >>> conda initialize >>> # !! Contents within this block are managed by 'conda init' !! @@ -75,6 +59,10 @@ export MANPATH="/usr/local/man:$MANPATH" # Bat export BAT_PAGER="less -R" +# Asdf + . /usr/local/opt/asdf/libexec/asdf.sh +source "${XDG_CONFIG_HOME:-$HOME/.config}/asdf-direnv/zshrc" + # Starship eval "$(starship init zsh)" @@ -160,17 +148,6 @@ unquarantine() { done } -# Auto change the nvm version based on a .nvmrc file based on the current directory. -# See https://github.com/creationix/nvm/issues/110#issuecomment-190125863 -autoload -U add-zsh-hook -load-nvmrc() { - if [[ -f .nvmrc && -r .nvmrc ]]; then - nvm use - fi -} -add-zsh-hook chpwd load-nvmrc -load-nvmrc - # fe [FUZZY PATTERN] - Open the selected file with the default editor # - Bypass fuzzy finder if there's only one match (--select-1) # - Exit if there's no match (--exit-0) @@ -323,11 +300,9 @@ antigen bundle jira antigen bundle man antigen bundle node antigen bundle npm -antigen bundle nvm antigen bundle pip antigen bundle pyenv antigen bundle python -antigen bundle rbenv antigen bundle rsync antigen bundle ssh-agent antigen bundle sudo @@ -368,6 +343,8 @@ alias gb='git branch' alias gba='git branch -a' alias gc='git commit -v' alias gca='git commit -v -a' +alias gcam='git commit --amend' +alias gcan='git commit --amend --no-edit' alias gd='git diff -- . ":(exclude)yarn.lock"' # Show differences between index and working tree alias gdc='git diff --cached' # Show changes in next commit (differences between index and last commit) alias gdh='git diff head' # Show difference between files in working tree and last commit