-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
174 lines (149 loc) · 5.22 KB
/
.zshrc
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
eval "$(/opt/homebrew/bin/brew shellenv)"
export ZSH="$HOME/.oh-my-zsh"
source "/opt/homebrew/opt/spaceship/spaceship.zsh"
zstyle ':omz:update' mode disabled # Disable automatic updates
ENABLE_CORRECTION="true"
COMPLETION_WAITING_DOTS="true" # Display red dots whilst waiting for completion.
ZSH_AUTOSUGGEST_STRATEGY=(history completion)
VI_MODE_SET_CURSOR=true
export EDITOR='vim'
export RPS1="%{$reset_color%}" # Disable default "<<<" NORMAL mode indicator in right prompt.
FZF_ALT_C_COMMAND="command fd --type d -E node_modules -E Library -E Desktop -E target -E dist -E .nuxt -E Applications -E coverage -E Documents -E Chrome\ Overrides -E Music -E Public -E Movies -E Pictures"
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
plugins=(
alias-finder
common-aliases
dirhistory
fzf
fzf-tab
gh
git
gitfast
macos
npm
safe-paste
vi-mode
volta
yarn
zsh-autosuggestions
zsh-interactive-cd
zsh-syntax-highlighting
)
source $ZSH/oh-my-zsh.sh
### KEY BINDINGS ###
bindkey '^[[1;5C' autosuggest-execute # Ctrl+RightArrow to accept and execute autosugges
bindkey "^[[1;3D" backward-word # Option+LeftArrow for previous word
bindkey "^[[1;3C" forward-word # Option+RightArrow for next word
bindkey "^H" backward-delete-word # Option+Backspace to delete previous word in WezTerm
bindkey "^W" backward-delete-word # Option+Backspace to delete previous word
bindkey "^A" vi-beginning-of-line # Cmd+LeftArrow to navigate to beginning of line in VSCode
bindkey "^[[1;2D" vi-beginning-of-line # Cmd+LeftArrow to navigate to beginning of line in WezTerm
bindkey "^E" end-of-line # Cmd+RightArrow to navigate to end of line in VSCode
bindkey "^[[1;2C" end-of-line # Cmd+RightArrow to navigate to end of line in VSCode
bindkey "^R" fzf-history-widget # Ctrl+R for history search
bindkey "^[c" fzf-cd-widget # Option+C to select the folder with FZF and cd to it in WezTerm
bindkey "ç" fzf-cd-widget # Option+C to select the folder with FZF and cd to it in VSCode
### FUNCTIONS ###
# Create a new directory and enter it.
function mkd() {
mkdir -p "$@" && cd "$_";
}
# Start an HTTP server from a directory, optionally specifying the port.
function server() {
python3 -m 'http.server' 8000;
}
# Run `dig` and display the most useful info.
function digga() {
dig +nocmd "$1" any +multiline +noall +answer;
}
function gacp() {
git add . && git commit -m "$1" && git push
}
function is_yarn() {
if [[ $(spaceship::upsearch "yarn.lock") ]]; then
return 0;
else
return 1;
fi
}
function is_npm() {
if [[ $(spaceship::upsearch "package-lock.json") ]]; then
return 0
else
return 1
fi
}
# Set SPACESHIP_CHAR_PREFIX to the logo of Node package manager
# on initialisation and after every cd.
function set_char_prefix() {
SPACESHIP_CHAR_PREFIX=''
if is_yarn; then SPACESHIP_CHAR_PREFIX=' ' fi
if is_npm; then SPACESHIP_CHAR_PREFIX="$SPACESHIP_CHAR_PREFIX " fi
}
function chpwd() {
emulate -L zsh
set_char_prefix
}
set_char_prefix
# JavaScript Package Manager
function jsp() {
if is_yarn; then yarn "$@"; else npm "$@"; fi
}
function jspa() {
if is_yarn; then yarn add "$@"; else npm install "$@"; fi
}
### ALIASES ###
alias cat="bat --theme='Visual Studio Dark+' --style=grid,header"
alias fd="fd -E=node_modules -E=temp -E=.DS_Store --no-ignore-vcs"
alias rm="safe-rm"
alias sed="gsed"
alias ytu="yarn run test:unit"
alias ytw="yarn run test:watch"
alias n="npm"
alias nb="npm run build"
alias nin="npm install"
alias nis="npm install -S"
alias nid="npm install -D"
alias nrun="npm run"
alias nd="npm run dev"
alias nt="npm run test"
alias ntu="npm run test:unit"
alias ntw="npm run test:watch"
alias nln="npm run lint"
alias nlnf="npm run lint --fix"
alias jspin="jsp install"
alias jspb="jsp run build"
alias jspad="jspa -D"
alias jsprun="jsp run"
alias jspd="jsp run dev"
alias jspt="jsp run test"
alias jsptu="jsp run test:unit"
alias jsptw="jsp run test:watch"
alias jspln="jsp run lint"
alias jsplnf="jsp run lint --fix"
alias gamend='git commit --amend --reuse-message=HEAD'
alias gd='git diff-index --quiet HEAD --; git diff --patch-with-stat'
alias gdstat='git diff --stat'
alias gmod='git merge origin/$(git_develop_branch)'
alias glog="git log --oneline --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short"
alias git_add_aliases="alias-finder -l 'git add'"
alias git_commit_aliases="alias-finder -l 'git commit'"
alias git_push_aliases="alias-finder -l 'git push'"
alias git_checkout_aliases="alias-finder -l 'git checkout'"
alias git_stash_aliases="alias-finder -l 'git stash'"
alias git_merge_aliases="alias-finder -l 'git merge'"
alias git_rebase_aliases="alias-finder -l 'git rebase'"
alias git_branch_aliases="alias-finder -l 'git branch'"
alias git_reset_aliases="alias-finder -l 'git reset'"
alias git_status_aliases="alias-finder -l 'git status'"
alias git_clone_aliases="alias-finder -l 'git clone'"
alias git_diff_aliases="alias-finder -l 'git diff'"
alias git_log_aliases="alias-finder -l 'git log'"
alias ghprvw="gh pr view --web"
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
alias localip="ipconfig getifaddr en0"
alias reload="exec $SHELL -l"
### IMPORTANT TO KEEP AT THE END ###
# ~/.extra can be used for other settings you don’t want to commit.
source ~/.extra.zsh