forked from mathiasbynens/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.bash_profile
174 lines (146 loc) · 5.98 KB
/
.bash_profile
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
unamestr=`uname`
if [ -f /etc/os-release ]; then
# freedesktop.org and systemd
. /etc/os-release
OS=$NAME
VER=$VERSION_ID
elif type lsb_release >/dev/null 2>&1; then
# linuxbase.org
OS=$(lsb_release -si)
VER=$(lsb_release -sr)
elif [ -f /etc/lsb-release ]; then
# For some versions of Debian/Ubuntu without lsb_release command
. /etc/lsb-release
OS=$DISTRIB_ID
VER=$DISTRIB_RELEASE
elif [ -f /etc/debian_version ]; then
# Older Debian/Ubuntu/etc.
OS=Debian
VER=$(cat /etc/debian_version)
elif [ -f /etc/SuSe-release ]; then
# Older SuSE/etc.
OS=SuSe
elif [ -f /etc/redhat-release ]; then
# Older Red Hat, CentOS, etc.
OS=RHEL
else
# Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
OS=$(uname -s)
VER=$(uname -r)
fi
# Load the shell dotfiles, and then some:
# * ~/.path can be used to extend `$PATH`.
# * ~/.extra can be used for other settings you don’t want to commit.
for file in ~/.{path,bash_prompt,exports,aliases,functions,extra}; do
[ -r "$file" ] && source "$file"
done
unset file
# Unicode settings needed for linux
export LANG=en_US.UTF8
export GDM_LANG=en_US.UTF8
# Case-insensitive globbing (used in pathname expansion)
shopt -s nocaseglob
# Preserve real-time bash history in multiple terminal windows
export HISTCONTROL=ignoredups:erasedups # no duplicate entries
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"
# 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
# Add tab completion for SSH hostnames based on ~/.ssh/config, ignoring wildcards
[ -e "$HOME/.ssh/config" ] && complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2 | tr ' ' '\n')" scp sftp ssh
# 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
# Autocomplete Grunt commands
#which grunt &> /dev/null && eval "$(grunt --completion=bash)"
# If possible, add tab completion for many more commands
[ -f /etc/bash_completion ] && source /etc/bash_completion
# MacPorts Installer addition on 2012-10-12_at_15:58:56: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Prevent the SUPER ANNOYING "temp file must be edited in place" error from crontab
alias crontab="VIM_CRONTAB=true crontab"
#alias wget="curl -O"
function vpn-connect {
echo "tell application \"System Events\"
tell current location of network preferences
set VPN to service \"1stDibs\" -- your VPN name here
if exists VPN then connect VPN
repeat while (current configuration of VPN is not connected)
delay 1
end repeat
end tell
end tell" | /usr/bin/env osascript
}
function vpn-disconnect {
"tell application \"System Events\"
tell current location of network preferences
set VPN to service \"1stDibs\" -- your VPN name here
if exists VPN then disconnect VPN
end tell
end tell" | /usr/bin/env osascript
}
cd ~/Configurations && git remote set-url origin [email protected]:cmckendry/Configurations.git
cd ~/Configurations && git pull &> /dev/null && git submodule update --init --recursive &> /dev/null &
disown $!
cd
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
[ -f /opt/boxen/env.sh ] && source /opt/boxen/env.sh
if [ -f ~/Configurations/secrets/.secrets ]; then
cd ~/Configurations/secrets && git remote set-url origin [email protected]:cmckendry/secrets.git
git pull
cd
source ~/Configurations/secrets/.secrets
else
git clone [email protected]:cmckendry/secrets.git ~/Configurations/secrets > /dev/null
source ~/Configurations/secrets/.secrets
fi
if [ ! -f ~/Configurations/.vim/bundle/YouCompleteMe/third_party/ycmd/ycm_core.so ]; then
echo "No YCM lib found"
if [[ "$unamestr" == 'Darwin' ]]; then
sudo chown -R `whoami` ~/Configurations/.vim/bundle/ && cd ~/Configurations/.vim/bundle/YouCompleteMe/ && ./install.py
fi
if [[ "$unamestr" == 'Linux' ]]; then
if [[ "$OS" == 'CentOS Linux' ]]; then
echo "YUM based YCM install"
sudo chown -R `whoami` ~/Configurations/.vim/bundle/ > /dev/null && sudo yum -y install gcc-c++ > /dev/null && cd ~/Configurations/.vim/bundle/YouCompleteMe/ && ./install.py &> /dev/null &
disown $!
cd
fi
fi
fi
## Passwordless SSH "phone home" functionality
## SUPER HACKY
# Grap epoch time for use as a (good enough) unique ID
#export NOW=`date +%s`
#if [ -z "$LC_IDENTIFICATION" ]; then
# # Generate the key/save to tmp file
# ssh-keygen -q -t rsa -N "" -f /tmp/$NOW
# # Drop the private key into an env variable
# export LC_IDENTIFICATION=`cat /tmp/$NOW`
# # Add the public key
# cat /tmp/$NOW.pub | sed "s/$USER@`hostname`/$NOW/" >> ~/.ssh/authorized_keys
# # Clean up
# rm -f /tmp/$NOW*
#else
# echo $LC_IDENTIFICATION | awk '{ for(i=4 ;i<30 ;i++) $i = $i"\n"}1' | head -n 26 > /tmp/$NOW
# echo '-----END RSA PRIVATE KEY-----' >> /tmp/$NOW
# chmod 400 /tmp/$NOW
# export HOME_KEY=/tmp/$NOW
# # Be careful not to get into a weird...loop thing
# unset LC_IDENTIFICATION
#fi
# Needed for VCL (and ffmpeg?) to handle subtitles correctly on macOS
if [[ "$unamestr" == 'Darwin' ]]; then
launchctl setenv FONTCONFIG_PATH /opt/X11/lib/X11/fontconfig
fi