-
Notifications
You must be signed in to change notification settings - Fork 1
/
sharedrc
176 lines (129 loc) · 4.27 KB
/
sharedrc
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
#######
# ENV #
#######
alias pts="cd ~/work/canva/web/src/base/proto"
export CANVA_REPO=~/work/canva
export DSL_REPO_DIR="/Users/mjbo/work/bulk-http-dsl"
export CANVA_REPO_DIR="/Users/mjbo/work/canva"
precmd() {
# sets the tab title to current dir
echo -ne "\e]1;${PWD##*/}\a"
}
export SBT_OPTS=$SBT_OPTS_VAL
export JAVA_OPTIONS=$JAVA_OPTIONS_VAL
alias onproxy='export JAVA_OPTIONS="$JAVA_OPTIONS_VAL -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=8888 -Dorg.asynchttpclient.useProxySelector=true"'
alias offproxy='JAVA_OPTIONS="$JAVA_OPTIONS_VAL"'
alias ondebug='export SBT_OPTS="$SBT_OPTS -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"'
alias offdebug='SBT_OPTS="$SBT_OPTS_VAL"'
enable-rustup() {
source $HOME/.cargo/env
}
export NVM_DIR="$HOME/.nvm"
enable-nvm() {
. "/usr/local/opt/nvm/nvm.sh"
}
enable-rbenv() {
eval "$(rbenv init -)"
}
enable-rvm() {
source /Users/Max/.rvm/scripts/rvm
}
#######
# FZF #
#######
# https://github.com/junegunn/fzf
# https://remysharp.com/2018/08/23/cli-improved
export FZF_DEFAULT_OPTS="--height 40% --reverse --border --ansi --preview 'head -32 {}' --bind='ctrl-o:execute(code {})+abort'"
export FZF_DEFAULT_COMMAND='fd --type file --follow --color=always --hidden --exclude .git'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
# if [ -x "$(command -v fzf)" ]; then
# [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# [ -f ~/.fzf.bash ] && source ~/.fzf.bash
# fi
ffv() { vim "$(fzf)"; }
alias fff="fzf"
alias preview="fzf --preview 'bat --color \"always\" {}'"
############
# DROP-INS #
############
if [ -x "$(command -v eza)" ]; then
alias ls="eza"
# sane default "exa -bghHliS"
alias lsa="ls --all --long --binary --header --time modified --git"
else
alias lsa="ls -alhG"
fi
if [ -x "$(command -v nvim)" ]; then
alias vim="nvim"
fi
if [ -x "$(command -v ccat)" ]; then
alias cat='ccat --bg="dark"'
fi
# https://remysharp.com/2018/08/23/cli-improved
if [ -x "$(command -v htop)" ]; then
alias top='sudo htop'
alias htopp="sudo htop --delay=300"
fi
if [ -x "$(command -v prettyping)" ]; then
alias ping='prettyping --nolegend'
fi
if [ -x "$(command -v ncdu)" ]; then
alias du='ncdu --color dark -rr -x --exclude .git --exclude node_modules'
fi
if [ -x "$(command -v fd)" ]; then
alias find='fd'
fi
if [ -x "$(command -v thefuck)" ]; then
eval $(thefuck --alias)
fi
alias cdw='fasd -e cd'
#########
# UTILS #
#########
github-clone() {
git clone "https://github.com/MaxwellBo/$1"
}
# https://stackoverflow.com/a/25620447/5835579
alias xmlextract="sed -e 's/<[^>]\{1,\}>//g; s/[^[:print:]]\{1,\}//g'"
docx() { unzip -p "$1" word/document.xml | xmlextract; }
docxn() { unzip -p "$1" word/document.xml | sed -e 's/<\/w:p>/\n/g; s/<[^>]\{1,\}>//g; s/[^[:print:]\n]\{1,\}//g'; }
###############
# FAT FINGERS #
###############
alias ripgrep="rg"
alias rgrep="rg"
alias rgl="rg --fixed-strings" # Treat the pattern as a literal string instead of a regular expression
##########
# PYTHON #
##########
alias localhost="python3 -m http.server"
alias workon="source .venv/bin/activate"
alias workoff="deactivate"
alias makevenv="python3 -m venv .venv && source .venv/bin/activate"
#######
# GIT #
#######
# http://gggritso.com/human-git-aliases
alias git-branches="git branch -a"
alias git-tags="git tag"
alias git-stashes="git stash list"
alias git-return-HEAD-to-staging="git reset --soft HEAD\^"
alias git-unstage="git reset -q HEAD --"
alias git-discard="git checkout --"
alias git-uncommit="git reset --mixed HEAD~"
alias git-amend="git commit --amend --verbose"
alias git-nevermind="!git reset --hard HEAD && git clean -d -f"
alias git-adog="git log --all --decorate --oneline --graph"
alias git-graph="git log --graph -10 --branches --remotes --tags --format=format:'%Cgreen%h %Creset• %<(75,trunc)%s (%cN, %cr) %Cred%d' --date-order"
# http://gitless.com/
alias git-cloak="git update-index --assume-unchanged"
alias git-uncloak="git update-index --no-assume-unchanged"
# https://sethrobertson.github.io/GitFixUm/fixup.html
alias git-peel="git reset HEAD~"
git-make-like-remote() {
git fetch origin && git reset --hard origin/`git rev-parse --abbrev-ref HEAD`
}
git-rebase-off-dev() {
git checkout dev && git pull && git checkout - && git rebase -i dev
}
alias git-diff-inline="git diff --word-diff=color"