-
Notifications
You must be signed in to change notification settings - Fork 1
/
.aliases
244 lines (208 loc) · 6.8 KB
/
.aliases
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
stty -ixon -ixoff
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias ls='/bin/ls -Ah -G'
alias l='/bin/ls -Ah -F -l -G'
alias em='emacsclient -nw'
alias gs='git status'
alias gd='git difftool origin/master'
alias gdo='git diff origin/master'
alias gdl='git diff --name-only HEAD~'
alias gdlo='git diff --name-only origin/master'
alias gca='git commit --amend --no-edit -a'
alias sync='git pull --rebase'
alias push='git push'
alias src='cd ~/src'
alias scratch='cd ~/src/scratch'
alias sa='source ~/.aliases'
alias va='vim ~/.aliases'
alias llog='tail -50 ~/LOG.txt'
alias vk='vim ~/.config/karabiner/karabiner.json'
alias vv='vim ~/.vimrc'
alias llog='tail -50 ~/LOG.txt'
# Swap ctrl and caps. Remove if configured via gnome-tweaks.
# Apply only to Linux (not Mac).
if [[ "$(uname)" != "Darwin" ]]; then
# setxkbmap -option "ctrl:swapcaps"
# xset r rate 135 30
echo -n
fi
if [[ "$(uname)" == "Darwin" ]]; then
# export JAVA_HOME="$(/usr/libexec/java_home -v 11)"
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home"
else
export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64"
fi
export GOPATH=$HOME/go
export PATH=/usr/local/opti/openssl@1.1/bin:$HOME/bin:$HOME/.fzf/bin:$GOPATH/bin:$JAVA_HOME/bin:$FLINK_HOME/bin:$PATH
# ZSH completions.
if [[ "$(basename ${SHELL})" == "zsh" && -o login && -o interactive ]]; then
if type brew &>/dev/null; then
FPATH=$(brew --prefix)/share/zsh-completions/:$FPATH
fi
autoload -U +X bashcompinit && bashcompinit
if [[ "$ZSH_THEME" != "lukerandall" ]]; then
omz theme use lukerandall
fi
export RPROMPT='[%D{%-I:%M:%S %p}]'
fi
if [[ "$(basename $SHELL)" == "bash" ]]; then
GIT_PROMPT_ONLY_IN_REPO=1
# Optional: Performance flags.
# GIT_PROMPT_SHOW_CHANGED_FILES_COUNT=0
# GIT_PROMPT_FETCH_REMOTE_STATUS=0
GIT_PROMPT_THEME=Single_line
[[ -f ~/.bash-git-prompt/gitprompt.sh ]] && source ~/.bash-git-prompt/gitprompt.sh
[[ -f "/usr/local/opt/bash-git-prompt/share/gitprompt.sh" ]] && source "/usr/local/opt/bash-git-prompt/share/gitprompt.sh"
# History tweaks.
# Source: http://unix.stackexchange.com/questions/1288/preserve-bash-history-in-multiple-terminal-windows
export HISTCONTROL=
export HISTSIZE=100000 # big big history
export HISTFILESIZE=100000 # big big history
shopt -s histappend # append to history, don't overwrite it
# Save and reload the history after each command finishes
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
fi
[[ -f ~/src/arcanist/resources/shell/bash-completion ]] && source ~/src/arcanist/resources/shell/bash-completion
[[ -f /usr/local/lib/bazel/bin/bazel-complete.bash ]] && source /usr/local/lib/bazel/bin/bazel-complete.bash
[[ -f /usr/local/etc/bash_completion.d/bazel-complete.bash ]] && source /usr/local/etc/bash_completion.d/bazel-complete.bash
[[ -x "$(command -v kubectl)" ]] && source <(kubectl completion bash)
if [[ "$(basename $SHELL)" == "zsh" ]]; then
# [[ -f /usr/local/git/contrib/completion/git-completion.zsh ]] && source /usr/local/git/contrib/completion/git-completion.zsh
:
else
[[ -f /usr/local/git/contrib/completion/git-completion.bash ]] && source /usr/local/git/contrib/completion/git-completion.bash
[[ -f /usr/local/etc/bash_completion ]] && source /usr/local/etc/bash_completion
fi
# heroku autocomplete setup
HEROKU_AC_BASH_SETUP_PATH=/Users/dkapoor/Library/Caches/heroku/autocomplete/bash_setup && test -f $HEROKU_AC_BASH_SETUP_PATH && source $HEROKU_AC_BASH_SETUP_PATH;
export FZF_CTRL_T_COMMAND='ag -g ""'
export EDITOR=vim
function reset() {
/usr/bin/reset $@
if [[ $(basename "$SHELL") == "bash" ]]; then
source ~/.bashrc
fi
if [[ $(basename "$SHELL") == "zsh" ]]; then
source ~/.zshrc
fi
}
function log() {
echo `date +"%Y-%m-%d %H:%M:%S %a -"` "$@" >> ~/LOG.txt
}
function gl() {
git l -30 "$@"
}
function l() {
gl "$@"
}
function b() {
git branch -vv
}
function sync() {
git pull --rebase origin master
git fetch --tags
}
function revert() {
if [ "$#" -ne 1 ]; then
echo 'Provide commit-ref (hash or HEAD)'
return 10
fi
git revert $1
}
function squash() {
if [ "$#" -ne 1 ]; then
squash $(current_branch)
return $?
fi
git checkout master
sync
git checkout $1
sync
local COMMITCOUNT=$(count_commit_diff)
if [[ ${COMMITCOUNT} -ne 1 ]]; then
git rebase -i master
else
echo "There is only 1 commit. Skipping squash."
fi
}
function cl() {
if [ "$#" -ne 1 ]; then
echo Provide branch-name
return 10
fi
git checkout -b $1 -t origin/master
}
function push() {
git push origin HEAD:master
}
function current_branch() {
git rev-parse --abbrev-ref HEAD
}
# Counts how many commits the local branch is behind origin.
function count_commit_diff() {
git rev-list origin..HEAD --count
}
# Authors of a git repository.
function authors() {
perl -e '$Author=1; $Approver=1; open(F, "git log --since 2015/01/01|");while (<F>) { $s{$1} +=$Author if /^Author:.+?<([^@]+)@/; if (/^\s+A=(.*)/) {map {$s{$_}+= $Approver} split(",", $1)}} for $k (keys %s) { $nk= substr($k, 0, -1); if (exists $s{$nk}){$s{$nk}+=$s{$k}; delete $s{$k}} } for $k (sort {$s{$b}<=> $s{$a}} keys %s) {next if $k =~/teste/;printf "%5i\t%s\n", $s{$k}, $k}' |head -10
}
function _branches() {
local prefix=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W "$(git branch)" -- ${prefix}) )
}
complete -F _branches prepare
complete -F _branches submit
complete -F _branches cl
complete -F _branches co
complete -F _branches squash
function root() {
cd "$(pwd | sed -e 's!\(/code/[^/]*\)/.*$!\1!')"
}
function h() {
local HOSTNAME="$(hostname -s)"
[[ "$HOSTNAME" == "dkapoor-26JJHD2" ]] && echo "mac" && return
[[ "$HOSTNAME" == "dev-dkapoor" ]] && echo "devapp" && return
[[ "$HOSTNAME" == "dev-dkapoor-2" ]] && echo "devapp" && return
echo ${HOSTNAME}
}
function lss() {
if [[ "$#" -eq 2 && "$2" == "-" ]]; then
cps $1 $2
return 0
fi
if [[ "$#" -ne 1 ]]; then
echo "Usage: lss s3://path/"
return 10
fi
local S3_PATH=$(echo $1 | sed -e 's!s3n://!s3://!' | sed -e 's!s3a://!s3://!')
aws s3 ls ${S3_PATH}
}
function cps() {
if [[ "$#" -ne 2 ]]; then
echo "Usage: cps s3://path/ /local/path"
return 10
fi
local S3_PATH=$(echo $1 | sed -e 's!s3n://!s3://!' | sed -e 's!s3a://!s3://!')
aws s3 cp ${S3_PATH} $2
}
function rms() {
if [[ "$#" -ne 1 ]]; then
echo "Usage: rms s3://path/"
return 10
fi
local S3_PATH=$(echo $1 | sed -e 's!s3n://!s3://!' | sed -e 's!s3a://!s3://!')
aws s3 rm --recursive ${S3_PATH}
}
function clean() {
git co master
git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d
}
function s3_retention() {
aws s3api get-bucket-lifecycle-configuration --bucket pinlogs | grep -C 5 "$@"
}
function psgrep() {
ps -ef | grep "$@"
}