-
Notifications
You must be signed in to change notification settings - Fork 0
/
.my_bash_aliases
175 lines (141 loc) · 4.61 KB
/
.my_bash_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
echo "[Running .my_bash_aliases"]
# Disable message about zsh being default shell
export BASH_SILENCE_DEPRECATION_WARNING=1
# vim: filetype=sh
export HOMEBREW_NO_ANALYTICS=1
# Use neovim
export EDITOR=nvim
alias vim="nvim"
alias oldvim=/usr/local/bin/vim
# shortcuts for neovim
export VIMCONFIG=~/.config/nvim
export VIMDATA=~/.local/share/nvim
# open neovim init.vim
alias myvim="nvim $VIMCONFIG/init.lua"
alias govim="cd $VIMCONFIG"
# Set GPG_TTY variable (https://www.gnupg.org/documentation/manuals/gnupg/Invoking-GPG_002dAGENT.html)
export GPG_TTY=$(tty)
# Print the current git author when the shell loads
# No longer using with switch to zsh
#if [[ -n $(which git) ]]; then
#printf "${COLOR_LIGHT_CYAN}Current git author:${COLOR_YELLOW} ${GIT_AUTHOR_NAME:-$(git config user.name)} <${GIT_AUTHOR_EMAIL:-$(git config user.email)}>\n${COLOR_NC}"
#fi
###
# Shortcuts to dot files
###
alias bp="vim ~/.bash_profile"
alias ghbp="vim ~/Code/dotfiles/.bash_profile"
alias sbp="source ~/.bash_profile"
# don't use vimrc with neovim
#alias vimrc="vim ~/.vimrc"
####
# Set up prompt
####
# No longer using with switch to zsh
#git_branch() {
#git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
#}
#PS1='\[\033[0;32m\]\[\033[0m\033[0;32m\]\u\[\033[0;36m\] @ \[\033[0;36m\]\h \w\[\033[0;32m\]$(__git_ps1)\n\[\033[0;32m\]└─\[\033[0m\033[0;32m\] \$\[\033[0m\033[0;32m\] ▶\[\033[0m\] '
# vim: filetype=sh
# export GOROOT=/usr/local/opt/go/libexec
alias be="bundle exec "
alias ..="cd .."
alias dv="cd ~/Development"
alias dev="cd ~/Development"
alias notes="cd /Users/$USER/Documents/Notes"
alias code="cd ~/Code"
alias dot="cd ~/Code/dotfiles"
alias jv="cd ~/Development/java"
alias mb="git branch -a | grep $USER"
alias canary='git push -f origin head:canary'
alias tmp='cd ~/tmp'
alias runBitgo='node ./bin/bitgo-express --disableproxy'
alias test-conversion='cd ~/Development/java && pants test metrics/s-c-signalfx::'
alias percent='~/code/percent/percent'
alias td="~/Code/dotfiles/today.sh"
alias yest="~/Code/dotfiles/yesterday.sh"
## Run compileKotlin gradle task
alias gck="./gradlew compileKotlin"
## Git branch
bb () {
read YYYY MM DD <<<$(date +'%Y %m %d')
git co -b "$USER.$YYYY$MM$DD.$1"
}
## Git store staged file
grsf () {
git restore --staged $1
git restore $1
}
## Searching
alias fn="find . -name "
alias fni="find . -iname "
fbb () {
PATTERN=$1
shift
rg -F $PATTERN $@ ~/Development/java/redact -tjava
}
## tell ripgrep to search hidden files
alias rg="rg --hidden --glob '!.git'"
## RUST
alias carg="cargo clean && cargo build && cargo test && cargo doc"
## Python 2 pyenv alias
# alias python="$(pyenv which python)"
# alias pip="$(pyenv which pip)"
## deploy diff for Java apps
remotediff () {
## arg1 = app, arg2 = env
dc=$([ "$2" = "prod" ] && echo "sjc2b" || echo "sjc1")
env=$([ "$2" = "prod" ] && echo "production" || echo "staging")
./remote $1 deploy-diff --dc $dc --env $env $3
}
## diffstat for diffing other repos
## USAGE: diffstat <sha1> <sha2>
diffstat () {
echo '```'
echo "Current: $1. Deploying $2"
git log $1...$2 $3 --pretty=format:'%h %ad %s - %an' --date=short --no-merges;
echo '```'
}
## GIT
alias gaa="git add -A "
alias gcmm="git commit -m "
alias gca="git commit --amend "
alias gds="git diff --staged"
alias gg="git log --decorate --oneline --graph --all"
alias ggg="git log --decorate --oneline --graph"
alias glno="git log --name-only"
alias gpr="gh pr create --web"
alias ghpr="git cmp"
# git log "short pretty"
alias glsp="git log --pretty=format:'%C(yellow)%h %Cred%ad %Cblue%an%Cgreen%d %Creset%s' --date=short --no-merges"
alias list-others="git branch | egrep -v 'sean' | egrep -v 'master' | xargs -n1 '-I{}' echo '{}'"
alias delete-others="git branch | egrep -v 'sean' | egrep -v 'master' | xargs -n1 '-I{}' git branch -D '{}'"
## prettyjson datafile.json
## cat datafile.json | prettyjson
alias prettyjson="ruby -e \"require 'json'; puts JSON.pretty_generate(JSON.parse(ARGF.read))\""
#####
## BITCOIN
#####
alias electrum-testnet="/Applications/Electrum.app/Contents/MacOS/Electrum --testnet"
#####
## database
#####
alias dumpbb="mysqldump --databases -u root redact_development > ~/tmp/db_back/redact-$(date +%F).sql"
dumpdb() {
mysqldump --databases -u root $1 > ~/tmp/db_back/$1-$(date +%F).sql
}
## load db
## create table redact_development;
## mysql -u root redact_development < ~/tmp/db_back/redact-2018-10-24.sql
## Git diff helper
difflog () {
git log $2...$3 --pretty=format:'%h %ad %s - %an' --date=short --no-merges $1
}
## find port in use
fport () {
sudo lsof -iTCP -sTCP:LISTEN -n -P | grep $1
}
# find ports from pid
fpid () {
lsof -Pan -p $1 -i
}