-
Notifications
You must be signed in to change notification settings - Fork 0
/
00-header
executable file
·38 lines (30 loc) · 1.21 KB
/
00-header
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
#!/usr/bin/env bash
# If the first argument passed to Bash starts with 'ssh ', don't do anything.
# This prevents duplicate output (once local; once remote) in cases where
# "bash -i -c $0 'ssh ...'" is used to directly start a SSH session.
if [[ $0 != 'ssh '* ]]; then
HEADER_SHOWN=motd
# Assume an SSH-session always sees a full MOTD(-like) header (unless it's
# running inside VS Code). Ubuntu up to 22.04 would set MOTD_SHOWN=pam, but
# since 23.04 there doesn't appear to be a better way to determine whether the
# MOTD was shown..
if [[ (-n "$SSH_CLIENT" || -n "$SSH_TTY") &&
"$TERM_PROGRAM" != "vscode" ]]; then
HEADER_SHOWN=motd-ssh
# Otherwise, if no MOTD was shown (or we're running inside VS Code's
# integrated terminal), we'll show a short/single-line header
elif
[ -z "$MOTD_SHOWN" ] || [ "$TERM_PROGRAM" == "vscode" ]
then
. /etc/update-motd.d/00-header
HEADER_SHOWN=short
fi
# In case of VS Code's intergrated terminal, we don't want to see any further
# (header) output generated by the bashrc.d-scripts
if [ "$TERM_PROGRAM" == vscode ]; then
unset HEADER_SHOWN
fi
export HEADER_SHOWN
# Separate MOTD/header from the rest of the output
printf "\n"
fi