-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zprofile
62 lines (58 loc) · 1.76 KB
/
.zprofile
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
# Stop here if we aren't interactive
[[ ! -o interactive ]] && return
# I'd like to use the window-title functions I've written, but they aren't
# loaded here yet. Loading that file itself in a login shell would be
# problematic.
if [[ -f ~/.window-name ]]; then
echo -ne "\e]2;$(cat ~/.window-name)\a"
fi;
if [[ $TERM == "screen" ]]; then
echo -ne '\ek'`hostname -s`'\e\\'
fi;
# When sshing into boxes, by default only TERM is passed and accepted. This
# means the remote side does not get our COLORTERM variable, and assumes we do
# not support colour. If we ended up passing in xterm-256color, we recreate
# COLORTERM for use when we execute a screen. We can then set our TERM within
# screen to screen-256color.
#
# The screen-256color check is necessary to ensure the inner-screen gets
# $COLORTERM set.
#
# This is complemented by settings in .shell/zsh/config.zsh
if [[ -z "$COLORTERM" ]]; then
if [[ "$TERM" == "xterm-256color" || "$TERM" == "screen-256color" ]]; then
export COLORTERM=truecolor
fi
fi
if [[ -x /usr/bin/screen ]]; then
# If we're not already in a screen, prompt for opening the outer screen.
if [[ "$TERM" != "screen" && -f ~/.outer ]]; then
screen -ls
echo -n "Run outer screen? "
local INPUT
read -qs INPUT
if [[ "$INPUT" == "y" ]]; then
screen -c .outerscreen -xR outer
else
screen -xR inner
fi
else
screen -xR inner
fi
elif [[ -x /usr/bin/tmux ]]; then
if [[ -z $TMUX ]]; then
if [[ -f ~/.outer ]]; then
echo -n "Run outer tmux? "
local INPUT
read -qs INPUT
if [[ "$INPUT" == "y" ]]; then
exec tmux new-session -A -s outer
else
exec tmux new-session -A -s inner
fi
else
unset TMUX
exec tmux new-session -A -s inner
fi
fi
fi