-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.zshrc
248 lines (207 loc) · 7.06 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# If you come from bash you might have to change your $PATH.
export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=/home/$USER/.oh-my-zsh
ZSH_THEME="intheloop"
if [ -e /usr/local/bin/starship ]; then
eval "$(starship init zsh)"
else
curl -fsSL https://starship.rs/install.sh | bash
fi
if [ -e /usr/bin/fortune ] && [ -e /usr/bin/cowsay ]; then
fortune | cowsay
else
echo "install fortune and cowsay for fun"
fi
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# custom fzf commands
export FZF_CTRL_T_OPTS="--preview '(highlight -O ansi -l {} 2> /dev/null || bat {} || tree -C {}) 2> /dev/null | head -200'"
export FZF_ALT_C_OPTS="--preview 'tree -C {} | head -200'"
export FZF_DEFAULT_COMMAND='rg --files'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
# Uncomment the following line to display red dots whilst waiting for completion.
COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
HIST_STAMPS="dd.mm.yyyy"
# Add wisely, as too many plugins slow down shell startup.
plugins=(
git
extract
zsh-autosuggestions
zsh-syntax-highlighting
autojump
fzf # find!
tmux
sudo # double esc
docker-compose
)
ZSH_TMUX_AUTOSTART=true
ZSH_TMUX_AUTONAME_SESSION=true
source $ZSH/oh-my-zsh.sh
# Zsh Customs
# source $ZSH_CUSTOM/plugins/forgit/forgit.plugin.sh
# source $ZSH_CUSTOM/plugins/zsh-interactive/zsh-interactive-cd.plugin.zsh
source $ZSH_CUSTOM/plugins/fzf-tab/fzf-tab.plugin.zsh
# zsh
setopt EXTENDED_HISTORY
setopt HIST_EXPIRE_DUPS_FIRST
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_IGNORE_SPACE
setopt HIST_FIND_NO_DUPS
setopt HIST_SAVE_NO_DUPS
setopt HIST_BEEP
alias reload!=". ~/.zshrc"
export EDITOR='vim'
export BROWSER='google-chrome-stable'
#general
alias zshrc='${=EDITOR} ~/.zshrc' # Quick access to the ~/.zshrc file
alias vimrc='${=EDITOR} ~/.vimrc' # Quick access to the ~/.vimrc file
alias ping='prettyping --nolegend'
alias dev="$HOME/dev"
alias du="ncdu -rr -x --color dark --exclude .git --exclude node_modules --exclude-caches"
alias help='tldr'
alias h="history"
alias lsbr="br -dp"
alias c="bat"
# php
#alias pat="php artisan tinker"
#alias pah="php artisan horizon"
#alias phpunit="vendor/bin/phpunit"
#alias pu="phpunit"
#alias pf="phpunit --filter"
# rails
alias rc='rails console'
alias rs='rails server'
alias rdm='rake db:migrate'
alias rdmr='rake db:migrate:redo'
alias rdr='rake db:rollback'
alias rds='rake db:seed'
alias rdrs='rake db:reset'
alias rr='rake routes'
# adonis
alias ads='adonis serve --dev --debug'
alias adrepl='adonis repl'
alias adt='adonis test -b'
alias admt='adonis migration:run'
alias admtr='adonis migration:rollback'
alias admts='adonis migration:status'
alias adroute='adonis route:list'
# git
alias gfaa="gfa && gco develop && ggpull && gco master && ggpull"
alias gcotop="git checkout $(git log --branches -1 --pretty=format:"%H")" # go to last commit from current branch
alias gsno="git show --name-only"
alias gsta="git stash save --include-untracked"
# alias gcupdate="git branch --merged | grep -v '\\*\\|master\\|develop' | xargs -n 1 git branch -d" # TEST delete local branch merged with master
# remove the commit from branch
alias grhd="git reset HEAD~ --hard"
# undo the last commit, but leave the changes available
alias grs="git reset HEAD~ --soft"
# docker
alias dcdangling="docker rmi \$(docker images -f \"dangling=true\" -q)"
# exa
alias ls="exa"
alias l="exa -a"
alias ll="exa -lgh"
alias la="exa -lagh"
alias lt="exa -T"
alias lg="exa -lagh --git"
# debian
# alias update="sudo apt update"
# alias upgrade="sudo apt upgrade"
# alias update_upgrade="sudo apt update && sudo apt upgrade"
# alias inst="sudo apt install"
# arch
alias update="sudo pacman -Syy"
alias upgrade="sudo pacman -Syu"
alias inst="sudo pacman -S"
alias clean='sudo pacman -Rs $(pacman -Qdtq)' # removes orphan packages from Archlinux
# file manipulation
alias cp='cp -iv'
alias mv='mv -iv'
alias rm='rm -i'
# react native
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk
export ANDROID_HOME=~/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/build-tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:~/Downloads/android-studio/bin
export SMPCPATH=/home/jonaselan/Desktop/setup-my-pc
export NODE_OPTIONS=--max-http-header-size=16384
# use vim for man pages
vman () {
man $1 | vim -
}
# gsf - easier way to deal with stashes
# type fstash to get a list of your stashes
# enter shows you the contents of the stash
gsf() {
while out=$(git stash list "$@" |
fzf --ansi --no-sort --reverse --print-query --query="$query" \
--expect=ctrl-m,ctrl-b,del \
--preview-window=bottom:60% \
--preview 'git show --patience --stat --pretty=oneline --color=always \
-p (echo {} | cut -d: -f1 | less -R)' \
# ^^ dropped quotes and changed $( to ( for fish subshell. ick.
);
do
# Tokenize selection by newline
selection=("${(f)out}")
# Keep the query accross fzf calls
query="$selection[1]"
# Represents the stash, e.g. stash{1}
reflog_selector=$(echo "$selection[3]" | cut -d ':' -f 1)
case "$selection[2]" in
# enter or ctrl-m is just a diff
ctrl-m)
git diff --patience --color=always -p "$reflog_selector" | less -R
;;
# ctrl-b checks out the stash as a branch and removes the stash
ctrl-b)
sha=$(echo "$selection[3]" | grep -o '[a-f0-9]\{7\}')
git stash branch "stash-$sha" "$reflog_selector"
break
;;
# del will drop the stash
del)
git stash drop "$reflog_selector"
;;
esac
done
}
# gswf - checkout git branch (including remote branches), sorted by most recent commit, limit 30 last branches
gswf() {
local branches branch
branches=$(git for-each-ref --count=30 --sort=-committerdate refs/heads/ --format="%(refname:short)") &&
branch=$(echo "$branches" |
fzf-tmux -d $(( 2 + $(wc -l <<< "$branches") )) +m) &&
git checkout $(echo "$branch" | sed "s/.* //" | sed "s#remotes/[^/]*/##")
}
# grf - restore changes
grf() {
local commits commit
commits=$(git log --pretty=oneline --abbrev-commit --reverse) &&
commit=$(echo "$commits" | fzf --tac +s +m -e) &&
git checkout $(echo "$commit" | sed "s/ .*//")
}
# gbclean Delete any local branches whose remote has been deleted
gbclean() {
git remote prune origin
git branch -vv | grep "origin/.*: gone]" | awk '{print $1}' | xargs git branch -D
}
compress() {
tar cvzf $1.tar.gz $1
}
copy() {
xclip -sel clip < $1
}
source /home/$USER/.config/broot/launcher/bash/br
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"