Show a welcome text on interactive shells running on Silverblue hosts
The welcome text uses the OSC 8 [1] escape sequence to add a hyperlink to the Silverblue documentation [2]. Silence a SC1003 [3] because the intention is to print the 'ESC \' string terminator (or ST), and not escape a single quote. [1] https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda [2] https://docs.fedoraproject.org/en-US/fedora-silverblue/toolbox/ [3] https://github.com/koalaman/shellcheck/wiki/SC1003 https://github.com/debarshiray/toolbox/pull/127
This commit is contained in:
parent
5d78707a21
commit
79f59b667b
4 changed files with 45 additions and 0 deletions
|
@ -8,6 +8,8 @@ project(
|
|||
go_md2man = find_program('go-md2man')
|
||||
shellcheck = find_program('shellcheck', required: false)
|
||||
|
||||
profiledir = get_option('profile_dir')
|
||||
|
||||
systemd_dep = dependency('systemd')
|
||||
tmpfilesdir = systemd_dep.get_pkgconfig_variable('tmpfilesdir')
|
||||
|
||||
|
@ -24,3 +26,4 @@ install_data(
|
|||
|
||||
subdir('data')
|
||||
subdir('doc')
|
||||
subdir('profile.d')
|
||||
|
|
6
meson_options.txt
Normal file
6
meson_options.txt
Normal file
|
@ -0,0 +1,6 @@
|
|||
option(
|
||||
'profile_dir',
|
||||
description: 'Directory for profile.d files to be read by the shell on start-up',
|
||||
type: 'string',
|
||||
value: '/usr/share/profile.d'
|
||||
)
|
10
profile.d/meson.build
Normal file
10
profile.d/meson.build
Normal file
|
@ -0,0 +1,10 @@
|
|||
toolbox_sh = files('toolbox.sh')
|
||||
|
||||
if shellcheck.found()
|
||||
test('shellcheck profile.d', shellcheck, args: ['--shell=sh', toolbox_sh])
|
||||
endif
|
||||
|
||||
install_data(
|
||||
toolbox_sh,
|
||||
install_dir: profiledir,
|
||||
)
|
26
profile.d/toolbox.sh
Normal file
26
profile.d/toolbox.sh
Normal file
|
@ -0,0 +1,26 @@
|
|||
[ "$BASH_VERSION" != "" ] || [ "$ZSH_VERSION" != "" ] || return 0
|
||||
[ "$PS1" != "" ] || return 0
|
||||
|
||||
toolbox_config="$HOME/.config/toolbox"
|
||||
host_welcome_stub="$toolbox_config/host-welcome-shown"
|
||||
|
||||
if [ -f /run/ostree-booted ] \
|
||||
&& ! [ -f "$host_welcome_stub" ]; then
|
||||
echo ""
|
||||
echo "Welcome to Fedora Silverblue. This terminal is running on the"
|
||||
echo "immutable host system. You may want to try out the Toolbox for a"
|
||||
echo "more traditional environment that allows package installation"
|
||||
echo "with DNF."
|
||||
echo ""
|
||||
printf "For more information, see the "
|
||||
# shellcheck disable=SC1003
|
||||
printf '\033]8;;https://docs.fedoraproject.org/en-US/fedora-silverblue/toolbox/\033\\documentation\033]8;;\033\\'
|
||||
printf ".\n"
|
||||
echo ""
|
||||
|
||||
mkdir -p "$toolbox_config"
|
||||
touch "$host_welcome_stub"
|
||||
fi
|
||||
|
||||
unset toolbox_config
|
||||
unset host_welcome_stub
|
Loading…
Reference in a new issue