-
Notifications
You must be signed in to change notification settings - Fork 2
/
.bashrc
157 lines (139 loc) · 3.74 KB
/
.bashrc
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
# .bashrc file
#
# Concepts:
#
# 1) .bashrc is the *non-login* config for bash, run in scripts and after
# first connection.
# 2) .bash_profile is the *login* config for bash, launched upon first connection.
# 3) .bash_profile imports .bashrc, but not vice versa.
# 4) .bashrc imports .bashrc_custom, which can be used to override
# variables specified here.
#
set +x
git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
# Safety
alias rm="rm -i"
alias mv="mv -i"
alias cp="cp -i"
set -o noclobber
# Nav
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias md='mkdir'
alias du='du -h --summarize'
alias l='ls'
alias ll='ls -Ahl'
alias tree='tree -A -C -L 2'
findfile () {
find . -iname "*$1*" -print
}
# Git
alias clean='git clean -xdf'
alias clone='git clone'
alias push='git push'
alias pushupstream='git push --set-upstream origin $(git_branch)'
alias pull='git pull'
function commit {
git commit -m "$*"
}
alias amend='git commit --amend'
alias amendall='git add --all && git commit --amend --no-edit'
alias fetch='git fetch && git status'
alias rebasemain='git fetch && git rebase origin/main'
function colored-git-status {
for i in `git diff --name-status`
do
if grep -q "^M" <<< "$i"
then
echo -e -n "$i$Yellow "
elif grep -q "^D" <<< "$i"
then
echo -e -n "$i$Red "
else
echo -e "$i$Color_Off"
fi
done
}
function st {
git status | sed -n '/Your/,/^$/p'
git status -s && echo
git log --pretty=format:"%h - <%an> %s (%cr)" --date=relative -3 && echo
}
alias addall='git add -A'
alias br='git branch -vv'
alias co='git checkout'
alias unstage='git reset HEAD'
alias log='git log --pretty=format:"%h - <%an> %s (%cr)" --date=relative -10'
alias stash='git stash save'
alias unstash='git stash pop'
alias stashes='git stash list'
alias pick='git cherry-pick'
alias trackedbranch='git rev-parse --abbrev-ref --symbolic-full-name @{u}'
alias grbc='git rebase --continue'
odd () {
git difftool -y -d $1..$2
}
function untilfail {
while "$@"; do :; done
}
# bazel
alias bzltest='bazel test --test_output=all --nocache_test_results'
# grep
function mygrep { grep -rnIi "$1" . --color; }
# grep options
export GREP_COLOR='1;31' # green for matches
# tmux
alias tmux='tmux -2'
# ls colors
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
# prevent accidental session exit when ctrl+d pressed
set -o ignoreeof
export EDITOR=vim
export VISUAL="$EDITOR"
export JAVA_HOME=/usr/local/lib/java/Contents/Home
[ -s "/Users/yasser.elsayed/.jabba/jabba.sh" ] && source "/Users/yasser.elsayed/.jabba/jabba.sh"
# Make prompt informative
if test -f ~/.ps1.sh; then
source ~/.ps1.sh
else
#Reset
Color_Off="\[\033[0m" # Text Reset
PathShort="\w"
NewLine="\n"
# Regular Colors
Black="\[\e[0;30m\]"
Red="\[\e[0;31m\]"
Green="\[\e[0;32m\]"
Yellow="\[\e[0;33m\]"
Blue="\[\e[0;34m\]"
Purple="\[\e[0;35m\]"
Cyan="\[\e[0;36m\]"
White="\[\e[0;37m\]"
GrayBG="\[\033[44m\]"
export PS1=$GrayBG$Green"[\h]":$Color_Off'$(git branch &>/dev/null;\
if [ $? -eq 0 ]; then \
echo "$(echo `git status` | grep "nothing to commit" > /dev/null 2>&1; \
if [ "$?" -eq "0" ]; then \
echo "'$Green'"\($(git_branch "(%s)")\);\
else \
echo "'$Red'"$(git_branch "{%s}");\
fi) '$Cyan'\w'$Color_Off''$NewLine''$Red'▶ '$Color_Off'"; \
fi)'
fi
alias k="kubectl $@"
alias kget="kubectl get $@"
alias kdesc="kubectl describe $@"
alias klogs="kubectl logs -f $@"
alias kpod="kubectl get pods $@ --sort-by=.metadata.creationTimestamp"
alias kdel="kubectl delete pod $@"
function kexec() {
pod="$1"
container="$2"
if [ -z $container ]; then kubectl exec -it "$pod" -- /bin/bash
else kubectl exec -it $pod -c $container -- /bin/bash
fi
}