-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzshrc_small
More file actions
78 lines (64 loc) · 1.81 KB
/
zshrc_small
File metadata and controls
78 lines (64 loc) · 1.81 KB
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
# Layout oh my zsh paths
export ZSH=${DOTFILES}/oh-my-zsh
ZSH_THEME="my_afowler"
ZSH_CUSTOM=${DOTFILES}/oh-my-zsh-custom
# Disable syntax highlighting on clr subnodes
if [[ ${HOSTNAME} =~ 'dn[0-9][0-9]' ]]; then
plugins=(
git
sudo
macos
)
else
plugins=(
git
sudo
macos
zsh-syntax-highlighting
)
fi
ZSH_DISABLE_COMPFIX=true
# Oh my zsh settings
source $ZSH/oh-my-zsh.sh 2>/dev/null
# Load zsh related settings
if [[ -d "${DOTFILES}/zshrc-settings" ]]; then
for file in ${DOTFILES}/zshrc-settings/*.zsh
do
source $file 2>/dev/null
done
fi
if [[ ${HOSTNAME} != 'm21003-lin.mpi-dortmund.mpg.de' && ${HOSTNAME} != 'markud-t460s' && $(hostname) != "MonsterMac.local" ]]
then
return 0
fi
# Load the ssh agent
GOT_AGENT=0
for FILE in $(find ${HOME}/.ssh/agent -type s -user ${LOGNAME} -name "*.agent.*" 2>/dev/null) $(find /tmp/ssh-* -type s -user ${LOGNAME} -name "agent.[0-9]*" 2>/dev/null) $(find /var/folders/w0/b0zq2yz53qggxbkdyxqmjrmh0000gp/T/ssh-* -type s -user ${LOGNAME} -name "agent.[0-9]*" 2>/dev/null)
do
SOCK_PID=${FILE##*.}
PID=$(ps -fu${LOGNAME}|awk '/ssh-agent/ && ( $2=='${SOCK_PID}' || $3=='${SOCK_PID}' || $2=='${SOCK_PID}' +1 ) {print $2}')
SOCK_FILE=${FILE}
SSH_AUTH_SOCK=${SOCK_FILE}; export SSH_AUTH_SOCK;
SSH_AGENT_PID=${PID}; export SSH_AGENT_PID;
keys=$(ssh-add -L)
if [[ $? != 2 ]]
then
GOT_AGENT=1
echo "Agent pid ${PID}"
for key in $(find ${HOME}/.ssh -name '*id_*' -not -name '*.pub')
do
public_key=$(cat ${key}.pub | awk '{ print $2 }')
if ! echo "${keys}" | grep -q "${public_key}"
then
ssh-add ${key}
fi
done
break
fi
#echo "Skipping pid ${PID}"
done
if [[ $GOT_AGENT = 0 ]]
then
eval `ssh-agent`
ssh-add
fi