forked from antfu/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
179 lines (145 loc) · 3.44 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
175
176
177
178
# git clone https://github.com/denysdovhan/spaceship-prompt.git "$ZSH_CUSTOM/themes/spaceship-prompt" --depth=1
# ln -s "$ZSH_CUSTOM/themes/spaceship-prompt/spaceship.zsh-theme" "$ZSH_CUSTOM/themes/spaceship.zsh-theme"
ZSH_THEME="spaceship"
# 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/agkozak/zsh-z $ZSH_CUSTOM/plugins/zsh-z
plugins=(
git
zsh-autosuggestions
zsh-syntax-highlighting
zsh-z
)
# https://ohmyz.sh/
source $HOME/.oh-my-zsh/oh-my-zsh.sh
# PATH
export PATH="$HOME/.local/bin:$PATH"
# -------------------------------- #
# Node Package Manager
# -------------------------------- #
# https://github.com/antfu/ni
alias nio="ni --prefer-offline"
alias s="nr start"
alias d="nr dev"
alias b="nr build"
alias bw="nr build --watch"
alias t="nr test"
alias tu="nr test -u"
alias tw="nr test --watch"
alias w="nr watch"
alias p="nr play"
alias c="nr typecheck"
alias lint="nr lint"
alias lintf="nr lint --fix"
alias release="nr release"
alias re="nr release"
# -------------------------------- #
# Git
# -------------------------------- #
# Go to project root
alias grt='cd "$(git rev-parse --show-toplevel)"'
alias gs='git status'
alias gp='git push'
alias gpf='git push --force'
alias gpft='git push --follow-tags'
alias gpl='git pull --rebase'
alias gcl='git clone'
alias gst='git stash'
alias grm='git rm'
alias gmv='git mv'
alias main='git checkout main'
alias gco='git checkout'
alias gcob='git checkout -b'
alias gb='git branch'
alias gbd='git branch -d'
alias grb='git rebase'
alias grbom='git rebase origin/master'
alias grbc='git rebase --continue'
alias gl='git log'
alias glo='git log --oneline --graph'
alias grh='git reset HEAD'
alias grh1='git reset HEAD~1'
alias ga='git add'
alias gA='git add -A'
alias gc='git commit'
alias gcm='git commit -m'
alias gca='git commit -a'
alias gcam='git add -A && git commit -m'
alias gfrb='git fetch origin && git rebase origin/master'
alias gxn='git clean -dn'
alias gx='git clean -df'
alias gsha='git rev-parse HEAD | pbcopy'
alias ghci='gh run list -L 1'
function glp() {
git --no-pager log -$1
}
function gd() {
if [[ -z $1 ]] then
git diff --color | diff-so-fancy
else
git diff --color $1 | diff-so-fancy
fi
}
function gdc() {
if [[ -z $1 ]] then
git diff --color --cached | diff-so-fancy
else
git diff --color --cached $1 | diff-so-fancy
fi
}
# -------------------------------- #
# Directories
#
# I put
# `~/i` for my projects
# `~/f` for forks
# `~/r` for reproductions
# -------------------------------- #
function i() {
cd ~/i/$1
}
function repros() {
cd ~/r/$1
}
function forks() {
cd ~/f/$1
}
function pr() {
if [ $1 = "ls" ]; then
gh pr list
else
gh pr checkout $1
fi
}
function dir() {
mkdir $1 && cd $1
}
function clone() {
if [[ -z $2 ]] then
hub clone "$@" && cd "$(basename "$1" .git)"
else
hub clone "$@" && cd "$2"
fi
}
# Clone to ~/i and cd to it
function clonei() {
i && clone "$@" && code . && cd ~2
}
function cloner() {
repros && clone "$@" && code . && cd ~2
}
function clonef() {
forks && clone "$@" && code . && cd ~2
}
function codei() {
i && code "$@" && cd -
}
function serve() {
if [[ -z $1 ]] then
live-server dist
else
live-server $1
fi
}
# alias
alias vi='lvim'