-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzshrc
165 lines (149 loc) · 3.82 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
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
# oh-my-zsh
if [[ ! -d $ZSH ]]; then
echo "Installing Oh My Zsh"
git clone git://github.com/robbyrussell/oh-my-zsh.git $ZSH
fi
# theme
ZSH_THEME="ys"
# plugins
ZSH_PLUGINS=$ZSH/custom/plugins
if [[ ! -d $ZSH_PLUGINS/zsh-autosuggestions ]]; then
git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_PLUGINS/zsh-autosuggestions
fi
unset ZSH_PLUGINS
plugins=(git sudo zsh-autosuggestions fzf pipenv nvm virtualenv genpass httpie timer)
# fix autocompletions if using several users
ZSH_DISABLE_COMPFIX=true
# change node version if .nvmrc is found
# https://stackoverflow.com/questions/73077938/how-to-correctly-setup-plugin-nvm-for-oh-my-zsh
zstyle ':omz:plugins:nvm' autoload yes
# source
source $ZSH/oh-my-zsh.sh
# go
export GOPATH=$HOME/golang
export GOBIN=$GOPATH/bin
# User configuration
path+=(
"$HOME/dotfiles/bin"
"$GOBIN"
)
# source local settings
if [ -f ~/.zshrc.local ]; then
source ~/.zshrc.local
fi
if [ -f ~/.zshrc.macos ]; then
source ~/.zshrc.macos
fi
if [ -f ~/.zshrc.linux ]; then
source ~/.zshrc.linux
fi
# forgit
# https://github.com/wfxr/forgit
if [[ ! -f ~/forgit/forgit.plugin.sh ]]; then
echo "Installing forgit"
git clone https://github.com/wfxr/forgit ~/forgit
fi
source ~/forgit/forgit.plugin.sh
# terminal colors
export TERM=xterm-256color
# alias
# simple python server
alias server='function() { python -m SimpleHTTPServer ${1:-8080} }'
# make dir and cd into it
alias mkcd='function() { mkdir $@ && cd $@ }'
# find and remove .orig files
alias rmorig='find . -name "*.orig" -delete'
# clear, twice for fun and to avoid scroll
alias cl="clear && clear"
# clear and list files
alias cls="clear && clear && ls"
# clear and search function (although I use rg now)
alias csF='clear && sF'
# search with results piped to less
alias lsF='function() { sF "$@" | less }'
# update outdated apps
alias brew-cask-upgrade='brew cask reinstall `brew cask outdated`'
# ip
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
# local ip
alias lip="ipconfig getifaddr en0"
# untar
alias untar='tar -zxvf '
# get checksum
alias sha='shasum -a 256 '
# recent git 3 branches
alias recent='npx git-recent -n 3'
# open repo url
alias repo='npx git-open'
# git rebase
alias gr='git rebase'
# git rebase interactive
alias gri='gr -i'
# git rebase origin/master
alias grm='gr origin/master'
# git fetchus (fetch + status)
alias gf='git fetchus'
# git checkout
alias gc='git checkout'
# git checkout -b
alias gcb='gc -b'
# git push
alias gp='git push'
# git plis
alias gpl='git plis'
# git clog
alias gl='git clog'
# git status
alias gs='git status'
# git diff
alias gd='git diff'
# git add
alias ga='git add'
# git add -p
alias gap='git add -p'
# git commit
alias gm='git commit'
# git commit -m
alias gmm="git commit -m"
# npm i
alias ni="npm i"
# npm start
alias ns="npm start"
# npm i + npm start
alias nis="ni && ns"
# git stash
alias gst="git stash"
# git stash pop
alias gsp="git stash pop"
# see changes for a given commit
function gdf () { git diff $1~ $1 }
# better git blame
function gbb() { git blame -s $1 | awk '{print $1,$3,$4}' | less}
# erase github token
# $ git credential-osxkeychain erase
# host=github.com
# protocol=https
# [Press Return] x2
# genpass
# https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/genpass
function gpwd() { genpass-xkcd "$@" }
# custom prompt
PROMPT="
%{$(virtualenv_prompt_info)%}\
%{$terminfo[bold]$fg[white]%}λ%{$reset_color%} \
%(#,%{$bg[yellow]%}%{$fg[black]%}%n%{$reset_color%},%{$fg[cyan]%}%n) \
%{$fg[white]%}@ \
%{$fg[green]%}%m \
%{$fg[white]%}in \
%{$fg[yellow]%}%~%{$reset_color%}\
${hg_info}\
${git_info}\
\
$exit_code
%{$terminfo[bold]$fg[red]%}$ %{$reset_color%}"
# nvm
export NVM_DIR=~/.nvm
source ~/.nvm/nvm.sh
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion