Skip to content

Instantly share code, notes, and snippets.

@Jaid
Last active June 30, 2023 03:31
Show Gist options
  • Save Jaid/e68ff74b342ffbf708620b37a617eb1d to your computer and use it in GitHub Desktop.
Save Jaid/e68ff74b342ffbf708620b37a617eb1d to your computer and use it in GitHub Desktop.
.env file template for user home directory, sourced in ~/.bashrc and ~/.zshrc
#!/bin/bash
function add {
regex="[[:space:]]+"
printf 'export %s=' "$1"
if [[ $2 =~ $regex ]]; then
printf %s "'$2'"
else
printf %s "$2"
fi
printf '\n'
}
# Common
add CASE_SENSITIVE true
add HIST_STAMPS dd.mm.yyyy
declare -r cores=$(nproc)
add MAKEFLAGS -j"$cores"
add EDITOR nano
# Netdata (human readable hostname)
add hostTitle "$(hostname)"
# Jaid tools
add githubUser Jaid
add npmUser jaid
add ownReposFolder "$HOME/git/jaid"
add otherReposFolder "$HOME/git/foreign"
add userBinFolder "$HOME/x"
add composeProjectFolder "$HOME/docker"
# Locale
systemLocale=en_US.utf8
personalLocale=de_DE.utf8
add LANG $systemLocale
add PERSONAL_LOCALE $personalLocale
add LANGUAGE $systemLocale
add LC_PAPER $personalLocale
add LC_ADDRESS $personalLocale
add LC_MONETARY $personalLocale
add LC_NUMERIC $systemLocale
add LC_TELEPHONE $personalLocale
add LC_IDENTIFICATION $systemLocale
add LC_MEASUREMENT $personalLocale
add LC_CTYPE $personalLocale
add LC_NAME $personalLocale
add LC_MESSAGES $systemLocale
add LC_TIME $personalLocale
# Generic accepter
add ACCEPT_EULA 1
# Node: https://nodejs.org/api/cli.html#environment-variables
fullRam=$(grep MemTotal /proc/meminfo | tr --squeeze ' ' | cut --fields 2 --delimiter ' ')
halfRam=$((fullRam / 2000))
nodeOptions="--max_old_space_size=$halfRam --experimental-vm-modules"
if [[ -n $NODE_OPTIONS ]]; then
add NODE_OPTIONS "$NODE_OPTIONS $nodeOptions"
else
add NODE_OPTIONS "$nodeOptions"
fi
add DISABLE_OPENCOLLECTIVE 1 # https://github.com/WebReflection/lightercollective#disabling-this-message
# gh: https://cli.github.com/manual/gh_help_environment
add GH_NO_UPDATE_NOTIFIER 1
add GLAMOUR_STYLE dark
# samba, see https://github.com/Jaid/setup-server/blob/main/composes/samba/docker-compose.yml
add sambaUser sambaUser
# rsyncd
add rsyncUser rsyncUser
- target: .env
userHome: true
backupExisting: true
permissions: 700
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment