-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bashrc
152 lines (114 loc) · 4.28 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
# === OPTIONS ===
# Case-insensitive globbing (used in pathname expansion)
shopt -s nocaseglob;
# Append to the Bash history file, rather than overwriting it
# http://www.biostat.jhsph.edu/~afisher/ComputingClub/webfiles/KasperHansenPres/IntermediateUnix.pdf
# https://unix.stackexchange.com/questions/48713/how-can-i-remove-duplicates-in-my-bash-history-preserving-order
export HISTCONTROL=ignoreboth:erasedups
export HISTSIZE=10000
shopt -s histappend;
shopt -s cmdhist;
# Autocorrect typos in path names when using `cd`
shopt -s cdspell;
# Enable some Bash 4 features when possible:
# * `autocd`, e.g. `**/qux` will enter `./foo/bar/baz/qux`
# * Recursive globbing, e.g. `echo **/*.txt`
for option in autocd globstar; do
shopt -s "$option" 2> /dev/null;
done;
# === EXPORTS ===
# Fastlane
# PATH
export PATH=$HOME/bin:/usr/local/bin:/usr/local/sbin:$PATH
eval $(/opt/homebrew/bin/brew shellenv)
export PATH=$(brew --prefix coreutils)/libexec/gnubin:$PATH
export PATH="/usr/local/opt/ruby/bin:$PATH"
export EDITOR='vim'
export NVM_DIR="$HOME/.nvm"
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh" # This loads nvm
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
export PATH="/opt/homebrew/opt/libressl/bin:$PATH"
# Always use color output for `ls`
alias ls="command ls ${colorflag}"
# === ALIAS ===
# Navigation
alias ..='cd ..'
alias ...='cd ../..'
# Detect which `ls` flavor is in use
if ls --color > /dev/null 2>&1; then # GNU `ls`
colorflag="--color"
else # OS X `ls`
colorflag="-G"
fi
alias ls="ls -lF ${colorflag}"
alias la="ls -laF ${colorflag}"
alias o='open'
alias o.='open .'
alias g='git'
alias gs='g s'
alias gl='g l'
alias gp='g pull'
alias gc='g c'
alias gadd='g add'
alias gadd.='g add .'
alias gpu='g push origin master'
alias ghead='g pull origin $(g rev-parse --abbrev-ref HEAD)'
# Grep
alias grep='grep --color=auto'
# Stopwatch
alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date'
# IP addresses
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
alias localip="ipconfig getifaddr en0"
alias ips="ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'"
# Lock the screen (when going AFK)
# Get week number
alias week='date +%V'
# Open workspace or project of current folder in Xcode
xc () {
if ls *.xcworkspace 1>/dev/null 2>&1; then
open *.xcworkspace
else
open *.xcodeproj
fi
}
xc12 () {
if ls *.xcworkspace 1>/dev/null 2>&1; then
open -a /Applications/Xcode12.app *.xcworkspace
else
open -a /Applications/Xcode12.app *.xcodeproj
fi
}
# Trash the derived data cache
alias dderived="trash ~/Library/Developer/Xcode/DerivedData"
# Start a small python web server from any directory
alias serve='python -m SimpleHTTPServer 8000'
alias vejr='curl wttr.in/copenhagen'
alias fuxcode="swift package -Xswiftc -I/usr/local/include -Xlinker -L/usr/local/lib generate-xcodeproj"
alias mysql5="mysql --host 0.0.0.0 --port 3307 -u root --password=winteriscoming"
alias mysql8="mysql --host 0.0.0.0 --port 3306 -u root --password=winteriscoming"
#alias redis-cli="docker exec -it redis redis-cli"
alias psql15="psql -h 0.0.0.0 -p 5432 -w -U postgres"
# === Completion ===
[[ -r "$(brew --prefix)/etc/profile.d/bash_completion.sh" ]] && . "$(brew --prefix)/etc/profile.d/bash_completion.sh"
# requires: brew install bash-completion
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
# Add tab completion for `defaults read|write NSGlobalDomain`
# You could just use `-g` instead, but I like being explicit
complete -W "NSGlobalDomain" defaults;
# Add `killall` tab completion for common apps
complete -o "nospace" -W "Contacts Calendar Dock Finder Mail Safari iTunes SystemUIServer Terminal Twitter" killall;
# === PS1 ===
source ~/.git-prompt.sh
source ~/.bash-ps1.sh
PROMPT_TITLE='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\007"'
export PROMPT_COMMAND="${PROMPT_COMMAND} ${PROMPT_TITLE}; "
export LC_TYPE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_CTYPE=en_US.UTF-8
GPG_TTY=$(tty)
export GPG_TTY
export PATH="/opt/homebrew/opt/postgresql@15/bin:$PATH"
export PATH="/opt/homebrew/opt/mysql-client/bin:$PATH"