summaryrefslogtreecommitdiffstats
path: root/.zprofile
blob: 18dd08aa2174e41df516689099e207858bd1a725 (plain)
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
if type startx &>/dev/null && ! pgrep X >/dev/null; then
	[[ -z $TTY ]] && TTY=$(tty)
	TTY=${TTY#/dev/}

	if [[ $TTY = tty1 ]]; then
		startx | systemd-cat -t Xorg-session
		exit
	fi
fi

if tty -s && [[ -z $DISPLAY ]]; then
	if type tmux &>/dev/null; then
		if [[ -z "$TMUX" ]]; then
			if ! tmux has -t "autosession"; then
				exec tmux new -s "autosession"
			else
				session=$(tmux new-session -t "autosession" -P -F "#{session_name}" -d)
				tmux attach-session -t $session
				tmux kill-session -t $session
				exit
			fi
		fi
	fi

	if [[ -z "$TMUX" ]]; then
		if type screen &>/dev/null && [[ -e ~/.screenrc-2 ]]; then
			screenname=$(screen -list | grep "screen-sh-2")
			if [ ! "$screenname" ]; then
				exec screen -S "screen-sh-2" -c ~/.screenrc-2
			elif echo $screenname | grep -q "Detached"; then
				exec screen -r screen-sh-2
			fi
		fi
	fi
fi