-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshrc
211 lines (172 loc) · 6.54 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
# Keep this one on top so all ls functionalities are replaced
# brew install lsd otherwise won't work
alias ls='lsd'
########################## Colors and Formatting ##########################
bold=$(tput bold);
reset=$(tput sgr0);
# Solarized colors, taken from http://git.io/solarized-colors.
black=$(tput setaf 0);
blue=$(tput setaf 33);
cyan=$(tput setaf 37);
green=$(tput setaf 64);
orange=$(tput setaf 166);
purple=$(tput setaf 125);
red=$(tput setaf 124);
violet=$(tput setaf 61);
white=$(tput setaf 15);
yellow=$(tput setaf 136);
# Highlight the user name when logged in as root.
if [[ "${USER}" == "root" ]]; then
userStyle="${red}";
else
userStyle="${orange}";
fi;
# Highlight the hostname when connected via SSH.
if [[ "${SSH_TTY}" ]]; then
hostStyle="${bold}${red}";
else
hostStyle="${yellow}";
fi;
########################## Easy Git ##########################
dir_status_check() {
inside_git_repo="$(git rev-parse --is-inside-work-tree 2>/dev/null)"
if [ "$inside_git_repo" ]; then
clear && git status
else
clear && ls
fi
}
prompt_git() {
local s='';
local branchName='';
# Check if the current directory is in a Git repository.
if [[ $(git rev-parse --is-inside-work-tree &>/dev/null; echo "${?}") == '0' ]]; then
# check if the current directory is in .git before running git checks
if [[ "$(git rev-parse --is-inside-git-dir 2> /dev/null)" == 'false' ]]; then
# Ensure the index is up to date.
git update-index --really-refresh -q &>/dev/null;
# Check for uncommitted changes in the index.
if [[ -n $(git diff --quiet --ignore-submodules --cached) ]]; then
s+='+';
fi;
# Check for unstaged changes.
if [[ -n $(git diff-files --quiet --ignore-submodules --) ]]; then
s+='!';
fi;
# Check for untracked files.
if [[ -n "$(git ls-files --others --exclude-standard)" ]]; then
s+='?';
fi;
# Check for stashed files.
if [[ $(git rev-parse --verify refs/stash 2> /dev/null) ]]; then
s+='$';
fi;
fi;
# Get the short symbolic ref.
# If HEAD isn’t a symbolic ref, get the short SHA for the latest commit
# Otherwise, just give up.
branchName="$(git symbolic-ref --quiet --short HEAD 2> /dev/null || \
git rev-parse --short HEAD 2> /dev/null || \
echo 'unknown')";
[ -n "${s}" ] && s=" [${s}]";
echo -e "${white}on ${blue}${1}${branchName}${2}${s}";
else
echo "";
fi;
}
########################## Paths ##########################
export PATH="$HOME/bin:$PATH";
export PATH="$HOME/.local/bin:$PATH"
export PATH="/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH"
export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:$PATH"
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"
# pyenv
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
# If pyenv is installed, this alias helps the `brew doctor` not complain about python config files
alias brew='env PATH=${PATH//$(pyenv root)/shims:/} brew'
# tfenv
export PATH="$HOME/.tfenv/bin:$PATH"
# nvm
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
sublime_link="/usr/local/bin/subl"
if [ -L ${sublime_link} ] && [ -e ${sublime_link} ] ; then
# The link exists and is good. Do nothing.
:
else
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
export EDITOR='subl -w'
fi
########################## zsh ##########################
precmd() {
setopt PROMPT_SUBST
PROMPT="${bold}${yellow}$(date "+%T") ${userStyle}kritin ${white}in ${green}%9c $(prompt_git)${reset}
$ "
# ${white}at ${cyan}${(%):-%m} // to display host address for cloud desktops
}
# Load the shell dotfiles, and then some:
# * ~/.path can be used to extend `$PATH`.
# * ~/.extra can be used for other settings you don't want to commit.
for file in ~/.{path,exports,aliases,functions,extra}; do
[ -r "$file" ] && [ -f "$file" ] && source "$file";
done;
unset file;
# git auto-complete
autoload -Uz compinit && compinit
# microsoft inshellisense
[ -f ~/.inshellisense/key-bindings.zsh ] && source ~/.inshellisense/key-bindings.zsh
# scala
# eval "$(scala-cli install completions --env --shell zsh)"
# >>> scala-cli completions >>>
# fpath=("/Users/krvij/Library/Application Support/ScalaCli/completions/zsh" $fpath)
# compinit
# <<< scala-cli completions <<<
########################## Gradle Commands ##########################
# No tests, lint, format
alias gbb='./gradlew build -x check'
alias gql='./gradlew lintAndAutofixGraphqlFiles'
alias gcb='./gradlew clean build spotlessApply checkstyleMain test'
alias gcbnt='./gradlew clean build spotlessApply checkstyleMain'
alias gb='./gradlew build spotlessApply checkstyleMain test'
alias gbnt='./gradlew spotlessApply checkstyleMain build'
alias gp='./gradlew preview'
alias gpr='./gradlew preview -PRUN_VALIDATIONS=true'
alias gpub='./gradlew publish'
alias gt='./gradlew test'
alias glint='./gradlew spotlessApply checkstyleMain'
alias gmvn='./gradlew publishToMavenLocal'
alias grun='./gradlew bootRun'
########################## Personal Aliases ##########################
alias grep='grep --color=auto'
alias sudo='sudo '
alias ..='cd ..'
alias c='clear'
alias la='ls -a'
alias c3='cal -3'
alias sz='source ~/.zshrc'
alias prof='subl ~/.zshrc'
alias all='/Users/krvij/base/coursera/pullall.sh'
alias diff='git diff -w'
alias diffc='git diff -w --cached'
alias st='dir_status_check'
alias pull='git pull origin $(git rev-parse --abbrev-ref HEAD) --rebase; git fetch;'
alias sync='git pull origin $(git rev-parse --abbrev-ref HEAD) --rebase; git fetch;'
alias main='git co main; sync'
alias br='git co -b'
alias add='git add .'
alias comm='git commit -m'
alias trim='git branch | grep -v "main" | grep -v "$(git rev-parse --abbrev-ref HEAD)" | xargs git branch -D'
alias pr='gh pr create'
alias ame='git commit --amend'
alias cane='git commit --amend --no-edit'
alias acane='git add . && git commit --amend --no-edit'
alias log='git log --graph --oneline --all'
alias doc='brew upgrade && brew cleanup && brew doctor'
alias gcp='git cherry-pick '
alias hm='cd ~/'
alias all='./pullall.sh;doc'
cd ~/; ls;