forked from divad12/khan-dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 18
/
.zprofile.khan
70 lines (62 loc) · 2.77 KB
/
.zprofile.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 .zprofile
#
# The difference between .zprofile and .profile is that the latter
# is called for all sh-compatible shells. So we put zshisms here
# and non-zshisms in .profile.
#
# The zsh shell does not load .profile itself, so we have to source
# .profile here.
# Add homebrew to path on M1 macs
if [ `uname -m` = "arm64" ]; then
export PATH=/opt/homebrew/bin:$PATH
fi
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.
# https://stackoverflow.com/questions/9901210/bash-source0-equivalent-in-zsh
SOURCE="${(%):-%N}"
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. Should use git-completion.zsh, but it seems problematic on mac
autoload -Uz compinit && compinit
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
# 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
# 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