diff --git a/main.zsh b/main.zsh index 522640a..3c5d839 100644 --- a/main.zsh +++ b/main.zsh @@ -1,9 +1,9 @@ if '[' '-z' "${ZSH_VERSION-}" ']' || ! 'eval' '[[ "$ZSH_VERSION" == (5.<8->*|<6->.*) ]]'; then - '.' "$Z4H"/zsh4humans/sc/exec-zsh-i || 'return' + '.' "$FOXSHELL"/foxshell/sc/exec-zsh-i || 'return' fi if [[ -x /proc/self/exe ]]; then - typeset -gr _z4h_exe=${${:-/proc/self/exe}:A} + typeset -gr _foxshell_exe=${${:-/proc/self/exe}:A} else () { emulate zsh -o posix_argzero -c 'local exe=${0#-}' @@ -14,26 +14,26 @@ else elif [[ -x $exe ]]; then exe=${exe:a} else - print -Pru2 -- "%F{3}z4h%f: unable to find path to %F{1}zsh%f" - return 1 - fi - typeset -gr _z4h_exe=${exe:A} + print -Pru2 -- "%F{3}foxshell%f: unable to find path to %F{1}zsh%f" + return 1 + fi + typeset -gr _foxshell_exe=${exe:A} } || return fi if ! { zmodload -s zsh/terminfo zsh/zselect && [[ -n $^fpath/compinit(#qN) ]] || - [[ $ZSH_PATCHLEVEL == zsh-5.8-0-g77d203f && $_z4h_exe == */bin/zsh && - -e ${_z4h_exe:h:h}/share/zsh/5.8/scripts/relocate ]] }; then - builtin source $Z4H/zsh4humans/sc/exec-zsh-i || return + [[ $ZSH_PATCHLEVEL == zsh-5.8-0-g77d203f && $_foxshell_exe == */bin/zsh && + -e ${_foxshell_exe:h:h}/share/zsh/5.8/scripts/relocate ]] }; then + builtin source $FOXSHELL/foxshell/sc/exec-zsh-i || return fi if [[ ! -o interactive ]]; then - # print -Pru2 -- "%F{3}z4h%f: starting interactive %F{2}zsh%f" - # This is caused by Z4H_BOOTSTRAPPING, so we don't need to consult ZSH_SCRIPT and the like. - exec -- $_z4h_exe -i || return + # print -Pru2 -- "%F{3}foxshell%f: starting interactive %F{2}zsh%f" + # This is caused by FOXSHELL_BOOTSTRAPPING, so we don't need to consult ZSH_SCRIPT and the like. + exec -- $_foxshell_exe -i || return fi -typeset -gr _z4h_opt='emulate -L zsh && +typeset -gr _foxshell_opt='emulate -L zsh && setopt typeset_silent pipe_fail extended_glob prompt_percent no_prompt_subst && setopt no_prompt_bang no_bg_nice no_aliases' @@ -42,21 +42,21 @@ zmodload -F zsh/files b:{zf_mkdir,zf_mv,zf_rm,zf_rmdir,zf_ln} || return zmodload -F zsh/stat b:zstat || return () { - if [[ $1 != $Z4H/zsh4humans/main.zsh ]]; then - print -Pru2 -- "%F{3}z4h%f: confusing %Umain.zsh%u location: %F{1}${1//\%/%%}%f" + if [[ $1 != $FOXSHELL/foxshell/main.zsh ]]; then + print -Pru2 -- "%F{3}foxshell%f: confusing %Umain.zsh%u location: %F{1}${1//\%/%%}%f" return 1 fi - if (( _z4h_zle )); then - typeset -gr _z4h_param_pat=$'ZDOTDIR=$ZDOTDIR\0Z4H=$Z4H\0Z4H_URL=$Z4H_URL' - typeset -gr _z4h_param_sig=${(e)_z4h_param_pat} - function -z4h-check-core-params() { - [[ "${(e)_z4h_param_pat}" == "$_z4h_param_sig" ]] || { - -z4h-error-param-changed + if (( _foxshell_zle )); then + typeset -gr _foxshell_param_pat=$'ZDOTDIR=$ZDOTDIR\0FOXSHELL=$FOXSHELL\0FOXSHELL_URL=$FOXSHELL_URL' + typeset -gr _foxshell_param_sig=${(e)_foxshell_param_pat} + function -foxshell-check-core-params() { + [[ "${(e)_foxshell_param_pat}" == "$_foxshell_param_sig" ]] || { + -foxshell-error-param-changed return 1 } } else - function -z4h-check-core-params() {} + function -foxshell-check-core-params() {} fi } ${${(%):-%x}:a} || return @@ -64,7 +64,7 @@ export -T MANPATH=${MANPATH:-:} manpath export -T INFOPATH=${INFOPATH:-:} infopath typeset -gaU cdpath fpath mailpath path manpath infopath -function -z4h-init-homebrew() { +function -foxshell-init-homebrew() { (( ARGC )) || return 0 local dir=${1:h:h} export HOMEBREW_PREFIX=$dir @@ -77,13 +77,13 @@ function -z4h-init-homebrew() { } if [[ $OSTYPE == darwin* ]]; then - if [[ ! -e $Z4H/cache/init-darwin-paths ]] || ! source $Z4H/cache/init-darwin-paths; then - autoload -Uz $Z4H/zsh4humans/fn/-z4h-gen-init-darwin-paths - -z4h-gen-init-darwin-paths && source $Z4H/cache/init-darwin-paths + if [[ ! -e $FOXSHELL/cache/init-darwin-paths ]] || ! source $FOXSHELL/cache/init-darwin-paths; then + autoload -Uz $FOXSHELL/foxshell/fn/-foxshell-gen-init-darwin-paths + -foxshell-gen-init-darwin-paths && source $FOXSHELL/cache/init-darwin-paths fi - [[ -z $HOMEBREW_PREFIX ]] && -z4h-init-homebrew {/opt/homebrew,/usr/local}/bin/brew(N) + [[ -z $HOMEBREW_PREFIX ]] && -foxshell-init-homebrew {/opt/homebrew,/usr/local}/bin/brew(N) elif [[ $OSTYPE == linux* && -z $HOMEBREW_PREFIX ]]; then - -z4h-init-homebrew {/home/linuxbrew/.linuxbrew,~/.linuxbrew}/bin/brew(N) + -foxshell-init-homebrew {/home/linuxbrew/.linuxbrew,~/.linuxbrew}/bin/brew(N) fi fpath=( @@ -92,10 +92,10 @@ fpath=( /opt/homebrew/share/zsh/site-functions(-/N) /usr{/local,}/share/zsh/{site-functions,vendor-completions}(-/N) $fpath - $Z4H/zsh4humans/fn) + $FOXSHELL/foxshell/fn) -autoload -Uz -- $Z4H/zsh4humans/fn/(|-|_)z4h[^.]#(:t) || return -functions -Ms _z4h_err +autoload -Uz -- $FOXSHELL/foxshell/fn/(|-|_)foxshell[^.]#(:t) || return +functions -Ms _foxshell_err () { path=(${@:|path} $path /snap/bin(-/N)) @@ -109,64 +109,64 @@ functions -Ms _z4h_err infopath=(${@:|infopath} $infopath '') } {${HOMEBREW_PREFIX:+$HOMEBREW_PREFIX/share/info},/opt/local/share/info}(-/N) -if [[ $ZSH_PATCHLEVEL == zsh-5.8-0-g77d203f && $_z4h_exe == */bin/zsh && - -e ${_z4h_exe:h:h}/share/zsh/5.8/scripts/relocate ]]; then - if [[ $TERMINFO != ~/.terminfo && $TERMINFO != ${_z4h_exe:h:h}/share/terminfo && - -e ${_z4h_exe:h:h}/share/terminfo/$TERM[1]/$TERM ]]; then - export TERMINFO=${_z4h_exe:h:h}/share/terminfo +if [[ $ZSH_PATCHLEVEL == zsh-5.8-0-g77d203f && $_foxshell_exe == */bin/zsh && + -e ${_foxshell_exe:h:h}/share/zsh/5.8/scripts/relocate ]]; then + if [[ $TERMINFO != ~/.terminfo && $TERMINFO != ${_foxshell_exe:h:h}/share/terminfo && + -e ${_foxshell_exe:h:h}/share/terminfo/$TERM[1]/$TERM ]]; then + export TERMINFO=${_foxshell_exe:h:h}/share/terminfo fi - if [[ -e ${_z4h_exe:h:h}/share/man ]]; then - manpath=(${_z4h_exe:h:h}/share/man $manpath '') + if [[ -e ${_foxshell_exe:h:h}/share/man ]]; then + manpath=(${_foxshell_exe:h:h}/share/man $manpath '') fi fi -path+=($Z4H/fzf/bin) -manpath+=($Z4H/fzf/man) +path+=($FOXSHELL/fzf/bin) +manpath+=($FOXSHELL/fzf/man) -: ${GITSTATUS_CACHE_DIR=$Z4H/cache/gitstatus} -: ${ZSH=$Z4H/ohmyzsh/ohmyzsh} -: ${ZSH_CUSTOM=$Z4H/ohmyzsh/ohmyzsh/custom} -: ${ZSH_CACHE_DIR=$Z4H/cache/ohmyzsh} +: ${GITSTATUS_CACHE_DIR=$FOXSHELL/cache/gitstatus} +: ${ZSH=$FOXSHELL/ohmyzsh/ohmyzsh} +: ${ZSH_CUSTOM=$FOXSHELL/ohmyzsh/ohmyzsh/custom} +: ${ZSH_CACHE_DIR=$FOXSHELL/cache/ohmyzsh} [[ $terminfo[Tc] == yes && -z $COLORTERM ]] && export COLORTERM=truecolor -if [[ $EUID == 0 && -z ~(#qNU) && $Z4H == ~/* ]]; then - typeset -gri _z4h_dangerous_root=1 +if [[ $EUID == 0 && -z ~(#qNU) && $FOXSHELL == ~/* ]]; then + typeset -gri _foxshell_dangerous_root=1 else - typeset -gri _z4h_dangerous_root=0 + typeset -gri _foxshell_dangerous_root=0 fi -[[ $langinfo[CODESET] == (utf|UTF)(-|)8 ]] || -z4h-fix-locale +[[ $langinfo[CODESET] == (utf|UTF)(-|)8 ]] || -foxshell-fix-locale -function -z4h-cmd-source() { - local _z4h_file _z4h_compile - zparseopts -D -F -- c=_z4h_compile -compile=_z4h_compile || return '_z4h_err()' - emulate zsh -o extended_glob -c 'local _z4h_files=(${^${(M)@:#/*}}(N) $Z4H/${^${@:#/*}}(N))' - if (( ${#_z4h_compile} )); then +function -foxshell-cmd-source() { + local _foxshell_file _foxshell_compile + zparseopts -D -F -- c=_foxshell_compile -compile=_foxshell_compile || return '_foxshell_err()' + emulate zsh -o extended_glob -c 'local _foxshell_files=(${^${(M)@:#/*}}(N) $FOXSHELL/${^${@:#/*}}(N))' + if (( ${#_foxshell_compile} )); then builtin set -- - for _z4h_file in "${_z4h_files[@]}"; do - -z4h-compile "$_z4h_file" || true - builtin source -- "$_z4h_file" + for _foxshell_file in "${_foxshell_files[@]}"; do + -foxshell-compile "$_foxshell_file" || true + builtin source -- "$_foxshell_file" done else - emulate zsh -o extended_glob -c 'local _z4h_rm=(${^${(@)_z4h_files:#$Z4H/*}}.zwc(N))' - (( ! ${#_z4h_rm} )) || zf_rm -f -- "${_z4h_rm[@]}" || true + emulate zsh -o extended_glob -c 'local _foxshell_rm=(${^${(@)_foxshell_files:#$FOXSHELL/*}}.zwc(N))' + (( ! ${#_foxshell_rm} )) || zf_rm -f -- "${_foxshell_rm[@]}" || true builtin set -- - for _z4h_file in "${_z4h_files[@]}"; do - builtin source -- "$_z4h_file" + for _foxshell_file in "${_foxshell_files[@]}"; do + builtin source -- "$_foxshell_file" done fi } -function -z4h-cmd-load() { +function -foxshell-cmd-load() { local -a compile - zparseopts -D -F -- c=compile -compile=compile || return '_z4h_err()' + zparseopts -D -F -- c=compile -compile=compile || return '_foxshell_err()' local -a files () { emulate -L zsh -o extended_glob - local pkgs=(${(M)@:#/*} $Z4H/${^${@:#/*}}) + local pkgs=(${(M)@:#/*} $FOXSHELL/${^${@:#/*}}) pkgs=(${^${(u)pkgs}}(-/FN)) local dirs=(${^pkgs}/functions(-/FN)) local funcs=(${^dirs}/^([_.]*|prompt_*_setup|README*|*~|*.zwc)(-.N:t)) @@ -182,28 +182,28 @@ function -z4h-cmd-load() { done } "$@" - -z4h-cmd-source "${compile[@]}" -- "${files[@]}" + -foxshell-cmd-source "${compile[@]}" -- "${files[@]}" } -function -z4h-cmd-init() { +function -foxshell-cmd-init() { if (( ARGC )); then - print -ru2 -- ${(%):-"%F{3}z4h%f: unexpected %F{1}init%f argument"} - return '_z4h_err()' + print -ru2 -- ${(%):-"%F{3}foxshell%f: unexpected %F{1}init%f argument"} + return '_foxshell_err()' fi - if (( ${+_z4h_init_called} )); then + if (( ${+_foxshell_init_called} )); then if [[ ${funcfiletrace[-1]} != zsh:0 ]]; then if '[' "${ZDOTDIR:-$HOME}" '=' "$HOME" ']'; then - >&2 'printf' '\033[33mz4h\033[0m: please use \033[4;32mexec\033[0m \033[32mzsh\033[0m instead of \033[32msource\033[0m \033[4m~/.zshrc\033[0m\n' + >&2 'printf' '\033[33mfoxshell\033[0m: please use \033[4;32mexec\033[0m \033[32mzsh\033[0m instead of \033[32msource\033[0m \033[4m~/.zshrc\033[0m\n' else - >&2 'printf' '\033[33mz4h\033[0m: please use \033[4;32mexec\033[0m \033[32mzsh\033[0m instead of \033[32msource\033[0m \033[4;33m"$ZDOTDIR"\033[0;4m/.zshrc\033[0m\n' + >&2 'printf' '\033[33mfoxshell\033[0m: please use \033[4;32mexec\033[0m \033[32mzsh\033[0m instead of \033[32msource\033[0m \033[4;33m"$ZDOTDIR"\033[0;4m/.zshrc\033[0m\n' fi 'return' '1' fi - print -ru2 -- ${(%):-"%F{3}z4h%f: %F{1}init%f cannot be called more than once"} - return '_z4h_err()' + print -ru2 -- ${(%):-"%F{3}foxshell%f: %F{1}init%f cannot be called more than once"} + return '_foxshell_err()' fi - -z4h-check-core-params || return - typeset -gri _z4h_init_called=1 + -foxshell-check-core-params || return + typeset -gri _foxshell_init_called=1 () { eval "$_z4h_opt"