Compare commits
2 commits
af1a7764bd
...
82a527b9c7
Author | SHA1 | Date | |
---|---|---|---|
82a527b9c7 | |||
2f72de023c |
1 changed files with 22 additions and 3 deletions
25
startup.sh
25
startup.sh
|
@ -1,9 +1,20 @@
|
|||
#!/usr/bin/env bash
|
||||
# shellcheck disable=SC2154
|
||||
set -eo pipefail
|
||||
|
||||
cd "${HOME:?}/.bashrc.d" || (
|
||||
# Define variables
|
||||
export "BASHRCD_FALLBACK=exec env --ignore-environment bash --norc --noprofile"
|
||||
|
||||
if [ -z "${BASHRCD_SYSTEM}" ]; then
|
||||
export "BASHRCD_HOMEDIR=${HOME:?}/.bashrc.d"
|
||||
else
|
||||
export "BASHRCD_HOMEDIR=/etc/bashrc.d"
|
||||
fi
|
||||
|
||||
# cd into to home directory
|
||||
cd "${BASHRCD_HOMEDIR}" || (
|
||||
echo ":: Can't cd into ${HOME:?}/.bashrc.d"
|
||||
exit 1
|
||||
${BASHRCD_FALLBACK}
|
||||
)
|
||||
|
||||
# Initialize basic stuff
|
||||
|
@ -13,7 +24,11 @@ cd "${HOME:?}/.bashrc.d" || (
|
|||
[[ -f "init.d/functions.sh" ]] && source "init.d/functions.sh"
|
||||
|
||||
# Create new configuration file
|
||||
[[ ! -f "config.sh" ]] && $(which cat) << EOF >> config.sh
|
||||
if [ ! -f "config.sh" ]; then
|
||||
if [ -n "${BASHRCD_SYSTEM}" ] && [ "${UID}" != "0" ]; then
|
||||
echo ":: Warning: Can't create system-wide configuration file as normal user."
|
||||
else
|
||||
$(which cat) << EOF >> config.sh
|
||||
#!/usr/bin/env bash
|
||||
CONFIG_FLOW_CONTROL=0
|
||||
CONFIG_AUTOSAVE_HISTORY=1
|
||||
|
@ -22,6 +37,8 @@ CONFIG_EDITOR=nano
|
|||
CONFIG_REPLACE_PKGMGR_ORIGINAL=pacman
|
||||
CONFIG_REPLACE_PKGMGR_REPLACEMENT=paru
|
||||
EOF
|
||||
fi
|
||||
fi
|
||||
|
||||
# Load configuration file
|
||||
source "config.sh"
|
||||
|
@ -62,3 +79,5 @@ for file in startup.d/*; do
|
|||
# shellcheck disable=SC1090
|
||||
source "${file}"
|
||||
done
|
||||
|
||||
set +eo pipefail
|
||||
|
|
Loading…
Reference in a new issue