mirror of
https://gitea.blesmrt.net/mikaela/shell-things.git
synced 2026-01-18 00:37:54 +01:00
{{bash,zsh}rc,profile}: explicitly exclude root from linuxbrew and programming language env tools
This commit is contained in:
parent
dc663490d9
commit
53da1bbed3
@ -1,3 +1,4 @@
|
|||||||
|
if [ "$(id -u)" != "0" ]; then
|
||||||
# This file is a snippet from my {bash,zsh}rc handling both Linuxbrew and
|
# This file is a snippet from my {bash,zsh}rc handling both Linuxbrew and
|
||||||
# different programming language version managers to ensure that when using
|
# different programming language version managers to ensure that when using
|
||||||
# the former, it will hopefully work for all users.
|
# 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_PREFIX=/home/linuxbrew/.linuxbrew
|
||||||
export HOMEBREW_REPOSITORY=/home/linuxbrew/.linuxbrew
|
export HOMEBREW_REPOSITORY=/home/linuxbrew/.linuxbrew
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|||||||
@ -265,6 +265,7 @@ export LOCALDOMAIN=.
|
|||||||
# regardless of whether DNSSEC=true or not.
|
# regardless of whether DNSSEC=true or not.
|
||||||
export RES_OPTIONS="timeout:1 attempts:5 rotate edns0 trust-ad"
|
export RES_OPTIONS="timeout:1 attempts:5 rotate edns0 trust-ad"
|
||||||
|
|
||||||
|
if [ "$(id -u)" != "0" ]; then
|
||||||
# https://github.com/go-nv/goenv
|
# https://github.com/go-nv/goenv
|
||||||
if [ -f /home/linuxbrew/.linuxbrew/opt/goenv/bin/goenv ]; then
|
if [ -f /home/linuxbrew/.linuxbrew/opt/goenv/bin/goenv ]; then
|
||||||
eval "$(/home/linuxbrew/.linuxbrew/opt/goenv/bin/goenv init -)" > /dev/null 2>&1
|
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
|
if [[ -d /run/host/var/home/linuxbrew && ! -d /home/linuxbrew ]]; then
|
||||||
sudo ln -nsfv /run/host/var/home/linuxbrew /home/linuxbrew
|
sudo ln -nsfv /run/host/var/home/linuxbrew /home/linuxbrew
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Removes duplicates from $PATH. Copied from https://unix.stackexchange.com/a/14896
|
# 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]}')
|
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 chattr="\chattr -V"
|
||||||
alias chmod="\chmod --verbose"
|
alias chmod="\chmod --verbose"
|
||||||
|
|
||||||
|
if [ "$(id -u)" != "0" ]; then
|
||||||
# https://github.com/nodejs/corepack/blob/v0.28.2/README.md#corepack-enable--name
|
# https://github.com/nodejs/corepack/blob/v0.28.2/README.md#corepack-enable--name
|
||||||
if hash corepack 2> /dev/null; then
|
if hash corepack 2> /dev/null; then
|
||||||
alias yarn="corepack yarn"
|
alias yarn="corepack yarn"
|
||||||
@ -634,9 +637,10 @@ if hash corepack 2> /dev/null; then
|
|||||||
if ! hash prettier 2> /dev/null; then
|
if ! hash prettier 2> /dev/null; then
|
||||||
alias prettier="pnpx prettier --cache --ignore-unknown"
|
alias prettier="pnpx prettier --cache --ignore-unknown"
|
||||||
fi
|
fi
|
||||||
else
|
elif [ "$(id -u)" != "0" ]; then
|
||||||
echo "Information: corepack is not installed."
|
echo "Information: corepack is not installed."
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# https://pnpm.io/installation#using-a-shorter-alias
|
# https://pnpm.io/installation#using-a-shorter-alias
|
||||||
alias pn="pnpm"
|
alias pn="pnpm"
|
||||||
|
|||||||
4
rc/zshrc
4
rc/zshrc
@ -228,6 +228,7 @@ export LOCALDOMAIN=.
|
|||||||
# regardless of whether DNSSEC=true or not.
|
# regardless of whether DNSSEC=true or not.
|
||||||
export RES_OPTIONS="timeout:1 attempts:5 rotate edns0 trust-ad"
|
export RES_OPTIONS="timeout:1 attempts:5 rotate edns0 trust-ad"
|
||||||
|
|
||||||
|
if [ "$(id -u)" != "0" ]; then
|
||||||
# https://github.com/go-nv/goenv
|
# https://github.com/go-nv/goenv
|
||||||
if [ -f /home/linuxbrew/.linuxbrew/opt/goenv/bin/goenv ]; then
|
if [ -f /home/linuxbrew/.linuxbrew/opt/goenv/bin/goenv ]; then
|
||||||
eval "$(/home/linuxbrew/.linuxbrew/opt/goenv/bin/goenv init -)" > /dev/null 2>&1
|
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
|
if [[ -d /run/host/var/home/linuxbrew && ! -d /home/linuxbrew ]]; then
|
||||||
sudo ln -nsfv /run/host/var/home/linuxbrew /home/linuxbrew
|
sudo ln -nsfv /run/host/var/home/linuxbrew /home/linuxbrew
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Removes duplicates from $PATH. Copied from https://unix.stackexchange.com/a/14896
|
# 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]}')
|
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
|
if ! hash prettier 2> /dev/null; then
|
||||||
alias prettier="corepack pnpx prettier --cache --ignore-unknown"
|
alias prettier="corepack pnpx prettier --cache --ignore-unknown"
|
||||||
fi
|
fi
|
||||||
else
|
elif [ "$(id -u)" != "0" ]; then
|
||||||
echo "Information: corepack is not installed."
|
echo "Information: corepack is not installed."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user