{{bash,zsh}rc,profile}: explicitly exclude root from linuxbrew and programming language env tools

This commit is contained in:
Aminda Suomalainen 2026-01-14 09:27:24 +02:00
parent dc663490d9
commit 53da1bbed3
Signed by: Mikaela
GPG Key ID: 99392F62BAE30723
3 changed files with 207 additions and 199 deletions

View File

@ -1,3 +1,4 @@
if [ "$(id -u)" != "0" ]; then
# This file is a snippet from my {bash,zsh}rc handling both Linuxbrew and
# different programming language version managers to ensure that when using
# the former, it will hopefully work for all users.
@ -70,3 +71,4 @@ if [ -d /home/linuxbrew/.linuxbrew/bin ]; then
export HOMEBREW_PREFIX=/home/linuxbrew/.linuxbrew
export HOMEBREW_REPOSITORY=/home/linuxbrew/.linuxbrew
fi
fi

View File

@ -265,6 +265,7 @@ export LOCALDOMAIN=.
# regardless of whether DNSSEC=true or not.
export RES_OPTIONS="timeout:1 attempts:5 rotate edns0 trust-ad"
if [ "$(id -u)" != "0" ]; then
# https://github.com/go-nv/goenv
if [ -f /home/linuxbrew/.linuxbrew/opt/goenv/bin/goenv ]; then
eval "$(/home/linuxbrew/.linuxbrew/opt/goenv/bin/goenv init -)" > /dev/null 2>&1
@ -334,6 +335,7 @@ fi
if [[ -d /run/host/var/home/linuxbrew && ! -d /home/linuxbrew ]]; then
sudo ln -nsfv /run/host/var/home/linuxbrew /home/linuxbrew
fi
fi
# Removes duplicates from $PATH. Copied from https://unix.stackexchange.com/a/14896
PATH=$(echo "$PATH" | awk -v RS=':' -v ORS=":" '!a[$1]++{if (NR > 1) printf ORS; printf $a[$1]}')
@ -623,6 +625,7 @@ alias mkdir="\mkdir --verbose"
alias chattr="\chattr -V"
alias chmod="\chmod --verbose"
if [ "$(id -u)" != "0" ]; then
# https://github.com/nodejs/corepack/blob/v0.28.2/README.md#corepack-enable--name
if hash corepack 2> /dev/null; then
alias yarn="corepack yarn"
@ -634,9 +637,10 @@ if hash corepack 2> /dev/null; then
if ! hash prettier 2> /dev/null; then
alias prettier="pnpx prettier --cache --ignore-unknown"
fi
else
elif [ "$(id -u)" != "0" ]; then
echo "Information: corepack is not installed."
fi
fi
# https://pnpm.io/installation#using-a-shorter-alias
alias pn="pnpm"

View File

@ -228,6 +228,7 @@ export LOCALDOMAIN=.
# regardless of whether DNSSEC=true or not.
export RES_OPTIONS="timeout:1 attempts:5 rotate edns0 trust-ad"
if [ "$(id -u)" != "0" ]; then
# https://github.com/go-nv/goenv
if [ -f /home/linuxbrew/.linuxbrew/opt/goenv/bin/goenv ]; then
eval "$(/home/linuxbrew/.linuxbrew/opt/goenv/bin/goenv init -)" > /dev/null 2>&1
@ -298,6 +299,7 @@ fi
if [[ -d /run/host/var/home/linuxbrew && ! -d /home/linuxbrew ]]; then
sudo ln -nsfv /run/host/var/home/linuxbrew /home/linuxbrew
fi
fi
# Removes duplicates from $PATH. Copied from https://unix.stackexchange.com/a/14896
PATH=$(echo "$PATH" | awk -v RS=':' -v ORS=":" '!a[$1]++{if (NR > 1) printf ORS; printf $a[$1]}')
@ -622,7 +624,7 @@ if hash corepack 2> /dev/null; then
if ! hash prettier 2> /dev/null; then
alias prettier="corepack pnpx prettier --cache --ignore-unknown"
fi
else
elif [ "$(id -u)" != "0" ]; then
echo "Information: corepack is not installed."
fi