-
Notifications
You must be signed in to change notification settings - Fork 0
/
.commonzshrc
54 lines (44 loc) · 2.33 KB
/
.commonzshrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
source "$HOME/.commonrc"
alias sr="export MANUALLY_SOURCING_RC=true && source $HOME/.zshrc && echo sourced zshrc;" # sr means: source .zshrc
alias vr="vim $HOME/.zshrc" # vr means: vim .zshrc
alias vczrc="vim $HOME/.commonzshrc" # vczrc means: vim .commonzshrc
#bindkey -v # for vi in terminal
bindkey "^?" backward-delete-char # fixes a bug that prevents you from hitting backspace in insert mode
# reverse search
bindkey '^r' history-incremental-search-backward
bindkey '^s' history-incremental-search-forward
setopt hist_ignore_all_dups # don't remember commands that are ran twice in a row
setopt hist_ignore_space # if a command starts with a space, it won't be added to the command history
# TODO: autocd will NOT remember your previous directory. unlike the cd_ alias. We should fix this
#setopt autocd # allows you to cd into a directory by just typing its name
# e.g. typing ".." will cd into the parent directory
# fzf complete makefile commands: https://stackoverflow.com/a/71966611/4647924
# but converted into zsh
_my_make_completion() {
local options
options=$(grep -oE '^[a-zA-Z0-9_.-]+[:]*[a-zA-Z0-9_.-]+:([^=]|$)' Makefile | sort | uniq | sed 's/[^a-zA-Z0-9_.-]*$//' | sed 's/[\\]//g' | fzf)
compadd -- ${options}
}
autoload -Uz compinit # needed for compdef https://unix.stackexchange.com/questions/339954/zsh-command-not-found-compinstall-compinit-compdef
compinit
compdef _my_make_completion make # Register the completion function with the make command
export NVM_DIR="$HOME/.nvm"
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh" # This loads nvm
[ -s "/usr/local/opt/nvm/etc/bash_completion" ] && . "/usr/local/opt/nvm/etc/bash_completion" # This loads nvm bash_completion
function parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
setopt prompt_subst # ensure prompt is reevaluated each time https://stackoverflow.com/questions/39689789/zsh-setopt-prompt-subst-not-working
PS1='$(printf "\e[1;31m%s: \e[1;33m%s \e[1;92m%s \e[1;0m" "$USER" "$PWD" "$(parse_git_branch)")
->'
# I tried putting this logic in .commonrc but it didn't work. it needs to be sourced at the end of the .zshrc file
export PATH="$HOME/.local/bin:$PATH"
eval "$(zoxide init zsh)"
function cd(){
z "$@" &&
pwd > "$HOME/.last_dir"
}
function ccd(){
zi "$@" &&
pwd > "$HOME/.last_dir"
}