-
Notifications
You must be signed in to change notification settings - Fork 2
/
shrc.sh
106 lines (85 loc) · 2.28 KB
/
shrc.sh
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
#!/bin/sh
# shellcheck disable=SC2155
# Setup paths
remove_from_path() {
[ -d "$1" ] || return
PATHSUB=":$PATH:"
PATHSUB=${PATHSUB//:$1:/:}
PATHSUB=${PATHSUB#:}
PATHSUB=${PATHSUB%:}
export PATH="$PATHSUB"
}
add_to_path_start() {
[ -d "$1" ] || return
remove_from_path "$1"
export PATH="$1:$PATH"
}
add_to_path_end() {
[ -d "$1" ] || return
remove_from_path "$1"
export PATH="$PATH:$1"
}
force_add_to_path_start() {
remove_from_path "$1"
export PATH="$1:$PATH"
}
quiet_which() {
command -v "$1" >/dev/null
}
add_to_path_start "/usr/local/sbin"
add_to_path_start "/home/linuxbrew/.linuxbrew/bin"
add_to_path_start "/usr/local/bin"
add_to_path_start "/opt/homebrew/bin"
add_to_path_start "$HOME/.bin"
# aliases
alias gl='git log --date=short --pretty=format:"%C(124)%ad %C(24)%h %C(34)%an %C(252)%s%C(178)%d" --stat'
alias gsign='git commit -C HEAD -S -s --amend'
alias reset-color="echo -e \"\e[39m\""
alias tmux-main="tmux new-session -A -s main"
if [ $MACOS ]
then
alias desktop="cd $HOME/Desktop"
fi
# android
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
# Cask
export PATH=$PATH:$HOME/.cask/bin
# Go
export GOPATH=$HOME/src/gobox
export PATH=$PATH:$GOPATH/bin
# Python
export PATH=$PATH:$HOME/Library/Python/2.7/bin/
# To fix libcurl errors from ETHO gem
# See https://stackoverflow.com/questions/50168647/multiprocessing-causes-python-to-crash-and-gives-an-error-may-have-been-in-progr
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
# MySQL 5.7
export MYSQLPATH=`brew --prefix [email protected] 2>/dev/null`
if [ -n "$MYSQLPATH" ]; then
export PATH=$MYSQLPATH/bin:$PATH
fi
# Lets use rbenv for now
quiet_which rbenv && eval "$(rbenv init -)"
genpasswd() {
local l=$1
[ "$l" == "" ] && l=16
tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs
}
# Docker
eval `boot2docker shellinit 2>/dev/null`
# Save directory changes
cd() {
builtin cd "$@" || return
[ "$TERMINALAPP" ] && command -v set_terminal_app_pwd >/dev/null \
&& set_terminal_app_pwd
pwd > "$HOME/.lastpwd"
}
# To create shortcuts:
# mkdir $HOME/ss; cd $HOME/ss
# ln -s source shortcut
ss() {
cd "$HOME/ss/$@" &>/dev/null || echo "unknown shortcut"
}
function replace-string {
git grep -l "$1" | xargs sed -i '' -e"s/$1/$2/g"
}