Created
March 10, 2023 11:47
-
-
Save davidnormo/717a92beb37f074c4ca704982674ad04 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. | |
# Initialization code that may require console input (password prompts, [y/n] | |
# confirmations, etc.) must go above this block; everything else may go below. | |
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then | |
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" | |
fi | |
# Config | |
# Load version control information | |
autoload -Uz vcs_info | |
precmd() { vcs_info } | |
# Format the vcs_info_msg_0_ variable | |
zstyle ':vcs_info:git:*' formats '(%b)' | |
# Set up the prompt (with git branch name) | |
setopt PROMPT_SUBST | |
PROMPT='%n/${PWD/#$HOME/~} ${vcs_info_msg_0_} > ' | |
ZSH_THEME=robbyrussell | |
# get opt + left/right working | |
bindkey "^[f" forward-word | |
bindkey "^[b" backward-word | |
# forward/backward subword movement | |
WORDCHARS='*?.[]~=&;!#$%^(){}<>' | |
# sigh... | |
bindkey "^A" vi-beginning-of-line | |
bindkey "^E" vi-end-of-line | |
# Aliases | |
alias refresh="source ~/.zshrc" #run this command after making changes to this file to apply them to that shell | |
alias ll="ls -AlFh" | |
br() { git symbolic-ref --short head } | |
# Setup path | |
export PATH="$HOME/.bin:$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:/usr/local/opt/ruby/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" | |
# fnm - Fast Node Manager | |
eval "$(fnm env --use-on-cd)" | |
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. | |
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh | |
export EDITOR=vim | |
export GIT_EDITOR=$(which vim) | |
source /usr/local/opt/powerlevel10k/powerlevel10k.zsh-theme | |
# Load Git completion | |
zstyle ':completion:*:*:git:*' script ~/.zsh/git-completion.bash | |
fpath=(~/.zsh $fpath) | |
autoload -Uz compinit && compinit | |
###-begin-npm-completion-### | |
# | |
# npm command completion script | |
# | |
# Installation: npm completion >> ~/.bashrc (or ~/.zshrc) | |
# Or, maybe: npm completion > /usr/local/etc/bash_completion.d/npm | |
# | |
if type complete &>/dev/null; then | |
_npm_completion () { | |
local words cword | |
if type _get_comp_words_by_ref &>/dev/null; then | |
_get_comp_words_by_ref -n = -n @ -n : -w words -i cword | |
else | |
cword="$COMP_CWORD" | |
words=("${COMP_WORDS[@]}") | |
fi | |
local si="$IFS" | |
IFS=$'\n' COMPREPLY=($(COMP_CWORD="$cword" \ | |
COMP_LINE="$COMP_LINE" \ | |
COMP_POINT="$COMP_POINT" \ | |
npm completion -- "${words[@]}" \ | |
2>/dev/null)) || return $? | |
IFS="$si" | |
if type __ltrim_colon_completions &>/dev/null; then | |
__ltrim_colon_completions "${words[cword]}" | |
fi | |
} | |
complete -o default -F _npm_completion npm | |
elif type compdef &>/dev/null; then | |
_npm_completion() { | |
local si=$IFS | |
compadd -- $(COMP_CWORD=$((CURRENT-1)) \ | |
COMP_LINE=$BUFFER \ | |
COMP_POINT=0 \ | |
npm completion -- "${words[@]}" \ | |
2>/dev/null) | |
IFS=$si | |
} | |
compdef _npm_completion npm | |
elif type compctl &>/dev/null; then | |
_npm_completion () { | |
local cword line point words si | |
read -Ac words | |
read -cn cword | |
let cword-=1 | |
read -l line | |
read -ln point | |
si="$IFS" | |
IFS=$'\n' reply=($(COMP_CWORD="$cword" \ | |
COMP_LINE="$line" \ | |
COMP_POINT="$point" \ | |
npm completion -- "${words[@]}" \ | |
2>/dev/null)) || return $? | |
IFS="$si" | |
} | |
compctl -K _npm_completion npm | |
fi | |
###-end-npm-completion-### | |
# history substring search | |
source /usr/local/share/zsh-history-substring-search/zsh-history-substring-search.zsh | |
bindkey '^[[A' history-substring-search-up | |
bindkey '^[[B' history-substring-search-down |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment