-
Notifications
You must be signed in to change notification settings - Fork 2
/
.sshrc
51 lines (42 loc) · 1023 Bytes
/
.sshrc
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
#!/usr/bin/env bash
# https://github.com/Russell91/sshrc
set -o vi
SHELL="$(which bash)"
TMUXDIR="/tmp/.${USER}"
TMUXSERVER="${TMUXDIR}/tmux"
export SHELL TMUXDIR TMUXSERVER
tmuxrc() {
if [[ ! -d "$TMUXDIR" ]]; then
rm -rf "$TMUXDIR"
mkdir -p "$TMUXDIR"
fi
rm -rf "${TMUXDIR}/.sshrc.d"
\cp -r \
"${SSHHOME}/.sshrc" \
"${SSHHOME}/bashsshrc" \
"${SSHHOME}/sshrc" \
"${SSHHOME}/.sshrc.d" \
"$TMUXDIR"
SSHHOME="$TMUXDIR" SHELL="${TMUXDIR}/bashsshrc" tmux -S "$TMUXSERVER" "$@"
}
# load system-wide profile.d if needed
if [[ -d /etc/profile.d ]]; then
for i in /etc/profile.d/*.sh; do
# shellcheck source=/dev/null
[[ -r "$i" ]] && source "$i"
done
unset i
fi
# Aliases
# shellcheck source=/dev/null
[[ -f "$SSHHOME/.sshrc.d/.aliases" ]] && source "$SSHHOME/.sshrc.d/.aliases"
# Tmux on startup
if [[ -r "$TMUXSERVER" ]]; then
if [[ -z "$TMUX" ]]; then
if tmuxrc ls &> /dev/null; then
exec tmux -S "$TMUXSERVER" a
else
tmuxrc new
fi
fi
fi