Last active
December 17, 2022 23:20
-
-
Save ormaaj/9dfd2e8049340e37bd488ec0c4ca4e85 to your computer and use it in GitHub Desktop.
/etc/profile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/true | |
# /etc/profile | |
if ${BASH_VERSION+\:} \false; then | |
[[ -o xtrace && -t /dev/fd/2 ]] && exec {BASH_XTRACEFD}>&2 | |
\shopt -u assoc_expand_once xpg_echo localvar_unset | |
\shopt -s extglob lastpipe globstar expand_aliases hostcomplete histappend checkwinsize cmdhist interactive_comments lithist no_empty_cmd_completion | |
# Wrapper to undefine a visible local variable, even in the current stack frame. Bash-only | |
function unset2 { command -- unset "$@"; } | |
(( BASH_VERSINFO[0] <= 5 && BASH_VERSINFO[1] <=2 )) && typeset -gx BASH_COMPAT=51 | |
else | |
\alias unset2=unset | |
fi | |
${ZSH_VERSION+\:} \false && \emulate ksh | |
${aliasrestore+\:} \false && \unset -v aliasrestore | |
case $(\readlink -qne /dev/fd/3) in | |
dash|*/dash) | |
\unalias -a | |
alias \ | |
shitshell=true \ | |
typeset=local \ | |
source='command .' \ | |
function='unalias eprofile; ' \ | |
eprofile='eprofile ()' | |
;; | |
*) | |
\exec 3<&- | |
aliasrestore=$(\alias -p) aliasrestore+=${aliasrestore:+$'\n\\'unset -v aliasrestore} | |
\unalias -a | |
alias shitshell=' ' | |
esac 3</proc/self/exe | |
case $KSH_VERSION in Version*|*PD\ KSH*|*MIRBSD*) alias -- {local,declare}=typeset; esac | |
case $(command -v let) in let) ;; *) let () while ${2+\:} return "$((! ( ${1:-0} )))"; do command shift; done; esac | |
function eprofile { | |
unset -f eprofile | |
if [ -t 0 ]; then | |
stty stop undef | |
stty -ixon -ctlecho iutf8 | |
fi | |
set +H -bo vi | |
umask 0027 | |
typeset x | |
export EDITOR PAGER | |
x=$(command -v nvimpager) | |
: "${EDITOR:=/bin/vi}" "${PAGER:=${x:-/usr/bin/less}}" | |
unset -v x | |
command . /etc/profile.env 2>&3 | |
unset2 -v ROOTPATH | |
for x in /etc/profile.d/*.sh; do | |
[ -r "$x" ] || continue | |
command . "$x" 2>&3 | |
done | |
if ${BASH_VERSION:+\:} false; then | |
: "${PS1:='\u@\h \w \$ '}" | |
else | |
PS1="${USER:-$(logname)}@$(uname -n) \$ " | |
fi | |
} 3>/dev/null | |
eprofile "$@" | |
shitshell eval ${BASH_VERSION+'--'} ${aliasrestore+"$aliasrestore"} | |
shitshell \unalias \shitshell | |
# vim: set ft=sh fenc=utf-8 ff=unix ts=4 noet : |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment