diff --git a/home/-shrc b/home/-shrc index a1e2ae6..e960044 100644 --- a/home/-shrc +++ b/home/-shrc @@ -1,6 +1,10 @@ #!/usr/bin/env false # for ash, dash, bash, and zsh. + [ -n "$ZSH_VERSION" -o -n "$BASH_VERSION" ] && FANCY=1 || FANCY=0 +if [ "$FANCY" = 0 ]; then + . ~/.prep # handle boring stuff like /etc/profile and $PATH +fi # {{{1 utilities @@ -66,7 +70,7 @@ fi # enable colors {{{2 -if [ "$FANCY" -eq 1 ]; then +if [ "$FANCY" = 1 ]; then # busybox is smart enough to ignore --color flags when unsupported. alias grep='grep --color=auto' alias ls='ls --color=auto' diff --git a/home/bashrc b/home/bashrc index f02965f..7c0fbd4 100644 --- a/home/bashrc +++ b/home/bashrc @@ -1,4 +1,5 @@ [ -z "$PS1" ] && return +. ~/.prep # handle boring stuff like /etc/profile and $PATH HISTCONTROL=erasedups HISTSIZE=1000 diff --git a/home/prep b/home/prep new file mode 100644 index 0000000..b0c0f4a --- /dev/null +++ b/home/prep @@ -0,0 +1,52 @@ +#!/usr/bin/env false +# for ash, dash, bash, and zsh. + +if [ -r /etc/msystem ]; then + # avoid sourcing /etc/profile because forking cygwin processes is awful. + . /etc/msystem # this doesn't fork anything, thankfully. + + # NOTE: never inherits parent process's PATH. does not add perl paths. + PATH="/usr/local/bin:/usr/bin:/bin" + PATH="$PATH:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem" + PATH="$PATH:/c/Windows/System32/WindowsPowerShell/v1.0/" + MANPATH="/usr/local/man:/usr/share/man:/usr/man:/share/man" + INFOPATH="/usr/local/info:/usr/share/info:/usr/info:/share/info" + SYSCONFDIR="${SYSCONFDIR:-/etc}" # not exported for some reason? + + CONFIG_SITE="/etc/config.site" + SHELL="/usr/bin/zsh" + + if [ "$MSYSTEM" = MSYS ]; then + PATH="$PATH:/opt/bin" + PKG_CONFIG_PATH="/usr/lib/pkgconfig:/usr/share/pkgconfig:/lib/pkgconfig" + else + PATH="$MINGW_PREFIX/bin:$PATH" + PKG_CONFIG_PATH="$MINGW_PREFIX/lib/pkgconfig:$MINGW_PREFIX/share/pkgconfig" + export ACLOCAL_PATH="$MINGW_PREFIX/share/aclocal:/usr/share/aclocal" + MANPATH="$MINGW_PREFIX/local/man:$MINGW_PREFIX/share/man:$MANPATH" + fi + + [ -n "${USER:=$USERNAME}" ] || USER="$(exec id -un)" # not much choice here + [ -n "${HOSTNAME:=$HOST}" ] || HOSTNAME="$(exec /usr/bin/hostname)" + + LANG="en_US.UTF-8" + [ -s /etc/localtime ] && TZ=":/etc/localtime" || TZ="America/Vancouver" + + TMP="/tmp"; TEMP="/tmp" + tmp="C:\\Users\\$USER\\AppData\\Local\\Temp"; temp="$tmp" + ORIGINAL_TMP="/c/Users/$USER/AppData/Local/Temp"; ORIGINAL_TEMP="$ORIGINAL_TMP" + export CONFIG_SITE HOSTNAME INFOPATH LANG MANPATH ORIGINAL_TEMP ORIGINAL_TMP PATH PKG_CONFIG_PATH SHELL TEMP TMP TZ USER temp tmp + +elif [ -r /etc/profile ]; then + if [ -n "$ZSH_VERSION" ]; then + emulate sh -c "source /etc/profile" + else + . /etc/profile + fi + +else # something's strange; set some sane defaults (from alpine) + export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" + export CHARSET="UTF-8" + export LANG="C.UTF-8" + export LC_COLLATE="C" +fi diff --git a/home/zshrc b/home/zshrc index 8b94d7f..8c91435 100644 --- a/home/zshrc +++ b/home/zshrc @@ -1,4 +1,4 @@ -[ -e /etc/profile ] && emulate sh -c "source /etc/profile" +. ~/.prep # handle boring stuff like /etc/profile and $PATH HISTFILE=~/.histfile HISTSIZE=99999 diff --git a/install b/install index 3ae9b62..9838bda 100755 --- a/install +++ b/install @@ -130,7 +130,7 @@ cd "${HOME:?HOME variable empty or unset}" || die "failed to change directory" backup_dir="$rc/backup-$(date -u '+%s')" [ ! -d "$backup_dir" ] || die "backup directory already exists" -for f in .bashrc .zshrc .-shrc .prezto-compinit .ls_colors \ +for f in .bashrc .zshrc .prep .-shrc .prezto-compinit .ls_colors \ .vimrc .inputrc .Xresources .screenrc .tmux.conf; do hardlink "$f" "$rc/home/${f#.}" done