122 lines
3.1 KiB
Bash
122 lines
3.1 KiB
Bash
#!/usr/bin/env zsh
|
|
|
|
# Speed up `brew install`
|
|
export HOMEBREW_NO_AUTO_UPDATE=1
|
|
export HOMEBREW_NO_INSTALL_CLEANUP=1
|
|
|
|
source $HOME/.env
|
|
source $HOME/.aliases
|
|
|
|
eval `dircolors $HOME/.dircolors`
|
|
|
|
# Load up and configure fzf, nvm, and zsh plugins
|
|
if [[ `uname` == Darwin ]]; then
|
|
# macOS
|
|
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
|
|
|
|
export NVM_DIR="$HOME/.nvm"
|
|
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh"
|
|
elif command -v apt &> /dev/null; then
|
|
# Debian
|
|
source /usr/share/doc/fzf/examples/completion.zsh
|
|
source /usr/share/doc/fzf/examples/key-bindings.zsh
|
|
|
|
export NVM_DIR="$HOME/.nvm"
|
|
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
|
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
|
|
elif command -v pacman &> /dev/null; then
|
|
# Arch
|
|
source /usr/share/fzf/completion.zsh
|
|
source /usr/share/fzf/key-bindings.zsh
|
|
|
|
[ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm"
|
|
source /usr/share/nvm/nvm.sh
|
|
source /usr/share/nvm/bash_completion
|
|
source /usr/share/nvm/install-nvm-exec
|
|
fi
|
|
|
|
# Load up Antigen and Zsh plugins
|
|
if [[ ! -f "${HOME}/.antigen/antigen.zsh" ]]; then
|
|
git clone https://github.com/zsh-users/antigen.git "${HOME}/.antigen"
|
|
fi
|
|
source "${HOME}/.antigen/antigen.zsh"
|
|
antigen bundle zsh-users/zsh-history-substring-search
|
|
antigen bundle zsh-users/zsh-syntax-highlighting
|
|
antigen apply
|
|
|
|
bindkey '^[[A' history-substring-search-up
|
|
bindkey '^[[B' history-substring-search-down
|
|
HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE=1
|
|
|
|
HISTFILE=$HOME/.zsh_history
|
|
HISTSIZE=1000000
|
|
SAVEHIST=1000000
|
|
|
|
zstyle ':completion:*' menu select
|
|
zstyle ':completion:*' completer _complete
|
|
zstyle ':completion:*' matcher-list '' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' '+l:|=* r:|=*'
|
|
|
|
autoload -U compinit && compinit
|
|
zmodload -i zsh/complist
|
|
|
|
unsetopt menu_complete
|
|
unsetopt flowcontrol
|
|
|
|
setopt prompt_subst
|
|
setopt always_to_end
|
|
setopt append_history
|
|
setopt auto_menu
|
|
setopt complete_in_word
|
|
setopt extended_history
|
|
setopt hist_expire_dups_first
|
|
setopt hist_ignore_dups
|
|
setopt hist_ignore_space
|
|
setopt hist_verify
|
|
setopt inc_append_history
|
|
setopt interactivecomments
|
|
setopt share_history
|
|
|
|
bindkey -v
|
|
bindkey '^a' beginning-of-line
|
|
bindkey '^e' end-of-line
|
|
|
|
git_prompt() {
|
|
BRANCH=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/*\(.*\)/\1/')
|
|
|
|
if [ ! -z $BRANCH ]; then
|
|
echo -n "%F{yellow}$BRANCH"
|
|
|
|
STATUS=$(git status --short 2> /dev/null)
|
|
|
|
if [ ! -z "$STATUS" ]; then
|
|
echo " %F{red}✗"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
PS1='
|
|
%F{blue}%~$(git_prompt)
|
|
%F{244}%# %F{reset}'
|
|
|
|
# Automatically use Node.js version specified in .nvmrc
|
|
autoload -U add-zsh-hook
|
|
|
|
load-nvmrc() {
|
|
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" != "$(nvm version)" ]; then
|
|
nvm use
|
|
fi
|
|
elif [ -n "$(PWD=$OLDPWD nvm_find_nvmrc)" ] && [ "$(nvm version)" != "$(nvm version default)" ]; then
|
|
echo "Reverting to nvm default version"
|
|
nvm use default
|
|
fi
|
|
}
|
|
|
|
add-zsh-hook chpwd load-nvmrc
|
|
load-nvmrc
|