forked from divad12/khan-dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 17
/
.bash_profile.khan
71 lines (63 loc) · 2.95 KB
/
.bash_profile.khan
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
################################################################################
# Khan Academy specific .bash_profile
#
# The difference between .bash_profile and .profile is that the latter
# is called for all sh-compatible shells. So we put bashisms here
# and non-bashisms in .profile.
#
# According to the bash manpage, if both .bash_profile and .profile
# exist, bash only reads the first one. So we have to source .profile
# manually.
if [ -z "$KA_DOTFILES_PROFILE_SOURCED" ]; then
# We check and then set this environment variable to ensure that we source
# .profile only once. Depending on a user's dotfile configuration, it
# might otherwise be possible to create an infinite loop of sourcing.
export KA_DOTFILES_PROFILE_SOURCED=1
if [ -s ~/.profile ]; then
source ~/.profile
fi
fi
unset KA_DOTFILES_PROFILE_SOURCED
# Figure out what directory we're *really* in (following symlinks).
# We need this because *-completion.bash are siblings to this script.
# http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # follow symlinks
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # resolve relative symlink
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
# Enable autocompletion for git
source "$DIR/git-completion.bash"
# Similarly for gcloud, if available
if ! which gcloud >/dev/null; then
GCLOUD_COMPLETION_FILE="$(basename "$(basename gcloud)")/completion.bash.inc"
if [ -f "$GCLOUD_COMPLETION_FILE" ]; then
source "$GCLOUD_COMPLETION_FILE"
fi
fi
# Stop OSX from constantly telling you that zsh is now the default shell.
# It is debatable which shell is better, but we don't need this warning.
export BASH_SILENCE_DEPRECATION_WARNING=1
# Add a brew86 alias if we're on an ARM architecture Mac
if [ "$(uname -s)" = "Darwin" ] && [ "$(uname -m)" = "arm64" ]; then
alias brew86="arch -x86_64 /usr/local/bin/brew $@"
fi
if [ "$(uname -s)" = "Darwin" ]; then
# Setting this allows us to store ssh-keys in the keychain without generating
# a warning. See ssh-add man page.
export APPLE_SSH_ADD_BEHAVIOR=macos
# Add ssh keys stored in the keychain to the ssh-agent
# Note: IF you have an identity in ~/.ssh and DO NOT have a passphrase already
# in the keychain, you will be prompted for a passphrase. This is because
# ssh-add will try to add the key to the agent, and will prompt for a
# passphrase if it doesn't have one in the keychain.
# If you have a passphrase in the keychain, you will not be prompted.
# If you don't have an identity in ~/.ssh, you will not be prompted.
# If you have an identity in ~/.ssh and DO have a passphrase in the keychain,
# you will not be prompted.
# (Being prompted should NOT happen if you ran ssh-add -K when you first
# created the key.)
ssh-add -K
fi