Improved startup performance and switched pkg managers

This commit is contained in:
Marcus Noble 2021-07-26 04:40:27 +01:00
parent d095509d3a
commit 3335b8fd82
4 changed files with 21 additions and 32 deletions

View File

@ -1,15 +1,16 @@
export ZSH="$HOME/.oh-my-zsh" export ZSH="$HOME/.oh-my-zsh"
plugins=( plugins=(
git asdf
docker aws
zsh-completions
zsh-syntax-highlighting zsh-syntax-highlighting
zsh-autosuggestions zsh-autosuggestions
) )
autoload -U compinit && compinit autoload -U compinit && compinit
fpath=($fpath ~/.zsh/completion) fpath=($fpath ~/.zsh/completion)
DISABLE_UNTRACKED_FILES_DIRTY="true"
source $ZSH/oh-my-zsh.sh source $ZSH/oh-my-zsh.sh
# History # History
@ -37,19 +38,17 @@ title() { export TITLE_OVERRIDDEN=1; echo -en "\e]0;$*\a"}
autotitle() { export TITLE_OVERRIDDEN=0 }; autotitle autotitle() { export TITLE_OVERRIDDEN=0 }; autotitle
# Condition checking if title is overridden # Condition checking if title is overridden
overridden() { [[ $TITLE_OVERRIDDEN == 1 ]]; } overridden() { [[ $TITLE_OVERRIDDEN == 1 ]]; }
# Echo asterisk if git state is dirty
gitDirty() { [[ $(git status 2> /dev/null | grep -o '\w\+' | tail -n1) != ("clean"|"") ]] && echo "*" }
# Show cwd when shell prompts for input. # Show cwd when shell prompts for input.
precmd() { precmd() {
if overridden; then return; fi if overridden; then return; fi
pwd=$(pwd) # Store full path as variable pwd=$(pwd) # Store full path as variable
cwd=${pwd##*/} # Extract current working dir only cwd=${pwd##*/} # Extract current working dir only
print -Pn "\e]0;$cwd$(gitDirty)\a" # Replace with $pwd to show full path print -Pn "\e]0;$cwd\a" # Replace with $pwd to show full path
} }
# Prepend command (w/o arguments) to cwd while waiting for command to complete. # Prepend command (w/o arguments) to cwd while waiting for command to complete.
preexec() { preexec() {
if overridden; then return; fi if overridden; then return; fi
printf "\033]0;%s\a" "${1%% *} | $cwd$(gitDirty)" # Omit construct from $1 to show args printf "\033]0;%s\a" "${1%% *} | $cwd" # Omit construct from $1 to show args
} }

View File

@ -1,23 +0,0 @@
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
load-nvmrc() {
local node_version="$(nvm version)"
local nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "$nvmrc_path" ]; then
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
if [ "$nvmrc_node_version" = "N/A" ]; then
nvm install
elif [ "$nvmrc_node_version" != "$node_version" ]; then
nvm use
fi
elif [ "$node_version" != "$(nvm version default)" ]; then
echo "Reverting to nvm default version"
nvm use 4 #default
fi
}
add-zsh-hook chpwd load-nvmrc
load-nvmrc

3
.tool-versions Normal file
View File

@ -0,0 +1,3 @@
nodejs 16.5.0
golang 1.16.2
kubectl 1.21.2

View File

@ -36,8 +36,16 @@ pre-reqs: ## Install all required binaries.
which btm > /dev/null || cargo install bottom; \ which btm > /dev/null || cargo install bottom; \
which procs > /dev/null || brew install procs; \ which procs > /dev/null || brew install procs; \
which dog > /dev/null || brew install dog; \ which dog > /dev/null || brew install dog; \
which asdf > /dev/null || brew install asdf; \
brew install gpg gawk coreutils; \
git clone https://github.com/zsh-users/zsh-autosuggestions $${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions; \ git clone https://github.com/zsh-users/zsh-autosuggestions $${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions; \
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting; git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting; \
asdf plugin add nodejs; \
asdf plugin add ruby; \
asdf plugin-add kubectl https://github.com/asdf-community/asdf-kubectl.git; \
RUST_WITHOUT=rust-docs asdf plugin-add rust https://github.com/asdf-community/asdf-rust.git; \
asdf plugin-add golang https://github.com/kennyp/asdf-golang.git; \
asdf install 1> /dev/null;
.PHONY: upgrade .PHONY: upgrade
upgrade: ## Upgrade all required binaries. upgrade: ## Upgrade all required binaries.
@ -70,8 +78,10 @@ upgrade: ## Upgrade all required binaries.
which btm > /dev/null && cargo install bottom; \ which btm > /dev/null && cargo install bottom; \
which procs > /dev/null && brew upgrade procs; \ which procs > /dev/null && brew upgrade procs; \
which dog > /dev/null && brew upgrade dog; \ which dog > /dev/null && brew upgrade dog; \
which asdf > /dev/null && brew upgrade asdf; \
cd $${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions && git pull && cd -; \ cd $${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions && git pull && cd -; \
cd $${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting && git pull && cd -; cd $${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting && git pull && cd -; \
asdf plugin update --all;
.PHONY: dotfiles .PHONY: dotfiles
dotfiles: ## Installs the dotfiles. dotfiles: ## Installs the dotfiles.