Fix main.zsh: Add foxshell function and update all z4h references
This commit is contained in:
parent
6375718f08
commit
5f07197c4c
1 changed files with 45 additions and 45 deletions
90
main.zsh
90
main.zsh
|
@ -360,7 +360,7 @@ function -foxshell-cmd-init() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -x /usr/lib/systemd/systemd || -x /lib/systemd/systemd ]]; then
|
if [[ -x /usr/lib/systemd/systemd || -x /lib/systemd/systemd ]]; then
|
||||||
_z4h_install_queue+=(systemd)
|
_foxshell_install_queue+=(systemd)
|
||||||
fi
|
fi
|
||||||
local brew
|
local brew
|
||||||
if [[ -n $HOMEBREW_REPOSITORY(#qNU) &&
|
if [[ -n $HOMEBREW_REPOSITORY(#qNU) &&
|
||||||
|
@ -368,113 +368,113 @@ function -foxshell-cmd-init() {
|
||||||
-v commands[brew] ]]; then
|
-v commands[brew] ]]; then
|
||||||
brew=homebrew-command-not-found
|
brew=homebrew-command-not-found
|
||||||
fi
|
fi
|
||||||
_z4h_install_queue+=(
|
_foxshell_install_queue+=(
|
||||||
zsh-history-substring-search zsh-autosuggestions zsh-completions
|
zsh-history-substring-search zsh-autosuggestions zsh-completions
|
||||||
zsh-syntax-highlighting terminfo fzf $brew powerlevel10k)
|
zsh-syntax-highlighting terminfo fzf $brew powerlevel10k)
|
||||||
(( install_tmux )) && _z4h_install_queue+=(tmux)
|
(( install_tmux )) && _foxshell_install_queue+=(tmux)
|
||||||
if ! -z4h-install-many; then
|
if ! -foxshell-install-many; then
|
||||||
[[ -e $Z4H/.updating ]] || -z4h-error-command init
|
[[ -e $FOXSHELL/.updating ]] || -foxshell-error-command init
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
if (( _z4h_installed_something )); then
|
if (( _foxshell_installed_something )); then
|
||||||
if [[ $TERMINFO != ~/.terminfo && -e ~/.terminfo/$TERM[1]/$TERM ]]; then
|
if [[ $TERMINFO != ~/.terminfo && -e ~/.terminfo/$TERM[1]/$TERM ]]; then
|
||||||
export TERMINFO=~/.terminfo
|
export TERMINFO=~/.terminfo
|
||||||
fi
|
fi
|
||||||
if (( need_restart )); then
|
if (( need_restart )); then
|
||||||
print -ru2 ${(%):-"%F{3}z4h%f: restarting %F{2}zsh%f"}
|
print -ru2 ${(%):-"%F{3}foxshell%f: restarting %F{2}zsh%f"}
|
||||||
exec -- $_z4h_exe -i || return
|
exec -- $_foxshell_exe -i || return
|
||||||
else
|
else
|
||||||
print -ru2 ${(%):-"%F{3}z4h%f: initializing %F{2}zsh%f"}
|
print -ru2 ${(%):-"%F{3}foxshell%f: initializing %F{2}zsh%f"}
|
||||||
export P9K_TTY=old
|
export P9K_TTY=old
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -w $TTY ]]; then
|
if [[ -w $TTY ]]; then
|
||||||
typeset -gi _z4h_tty_fd
|
typeset -gi _foxshell_tty_fd
|
||||||
sysopen -o cloexec -rwu _z4h_tty_fd -- $TTY || return
|
sysopen -o cloexec -rwu _foxshell_tty_fd -- $TTY || return
|
||||||
typeset -gri _z4h_tty_fd
|
typeset -gri _foxshell_tty_fd
|
||||||
elif [[ -w /dev/tty ]]; then
|
elif [[ -w /dev/tty ]]; then
|
||||||
typeset -gi _z4h_tty_fd
|
typeset -gi _foxshell_tty_fd
|
||||||
if sysopen -o cloexec -rwu _z4h_tty_fd -- /dev/tty 2>/dev/null; then
|
if sysopen -o cloexec -rwu _foxshell_tty_fd -- /dev/tty 2>/dev/null; then
|
||||||
typeset -gri _z4h_tty_fd
|
typeset -gri _foxshell_tty_fd
|
||||||
else
|
else
|
||||||
unset _z4h_tty_fd
|
unset _foxshell_tty_fd
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -v _z4h_tty_fd && (-n $Z4H_SSH && -n $_Z4H_SSH_MARKER || -n $_Z4H_TMUX) ]]; then
|
if [[ -v _foxshell_tty_fd && (-n $FOXSHELL_SSH && -n $_FOXSHELL_SSH_MARKER || -n $_FOXSHELL_TMUX) ]]; then
|
||||||
typeset -gri _z4h_can_save_restore_screen=1 # this parameter is read by p10k
|
typeset -gri _foxshell_can_save_restore_screen=1 # this parameter is read by p10k
|
||||||
else
|
else
|
||||||
typeset -gri _z4h_can_save_restore_screen=0 # this parameter is read by p10k
|
typeset -gri _foxshell_can_save_restore_screen=0 # this parameter is read by p10k
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if (( _z4h_zle )) && zstyle -t :z4h:direnv enable && [[ -e $Z4H/cache/direnv ]]; then
|
if (( _foxshell_zle )) && zstyle -t :foxshell:direnv enable && [[ -e $FOXSHELL/cache/direnv ]]; then
|
||||||
-z4h-direnv-init 0 || return '_z4h_err()'
|
-foxshell-direnv-init 0 || return '_foxshell_err()'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local rc_zwcs=($ZDOTDIR/{.zshenv,.zprofile,.zshrc,.zlogin,.zlogout}.zwc(N))
|
local rc_zwcs=($ZDOTDIR/{.zshenv,.zprofile,.zshrc,.zlogin,.zlogout}.zwc(N))
|
||||||
if (( $#rc_zwcs )); then
|
if (( $#rc_zwcs )); then
|
||||||
-z4h-check-rc-zwcs $rc_zwcs || return '_z4h_err()'
|
-foxshell-check-rc-zwcs $rc_zwcs || return '_foxshell_err()'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
typeset -gr _z4h_orig_shell=${SHELL-}
|
typeset -gr _foxshell_orig_shell=${SHELL-}
|
||||||
} || return
|
} || return
|
||||||
|
|
||||||
: ${ZLE_RPROMPT_INDENT:=0}
|
: ${ZLE_RPROMPT_INDENT:=0}
|
||||||
|
|
||||||
# Enable Powerlevel10k instant prompt.
|
# Enable Powerlevel10k instant prompt.
|
||||||
(( ! _z4h_zle )) || zstyle -t :z4h:powerlevel10k channel none || () {
|
(( ! _foxshell_zle )) || zstyle -t :foxshell:powerlevel10k channel none || () {
|
||||||
local user=${(%):-%n}
|
local user=${(%):-%n}
|
||||||
local XDG_CACHE_HOME=$Z4H/cache/powerlevel10k
|
local XDG_CACHE_HOME=$FOXSHELL/cache/powerlevel10k
|
||||||
[[ -r $XDG_CACHE_HOME/p10k-instant-prompt-$user.zsh ]] || return 0
|
[[ -r $XDG_CACHE_HOME/p10k-instant-prompt-$user.zsh ]] || return 0
|
||||||
builtin source $XDG_CACHE_HOME/p10k-instant-prompt-$user.zsh
|
builtin source $XDG_CACHE_HOME/p10k-instant-prompt-$user.zsh
|
||||||
}
|
}
|
||||||
|
|
||||||
local -i z4h_no_flock
|
local -i foxshell_no_flock
|
||||||
|
|
||||||
{
|
{
|
||||||
() {
|
() {
|
||||||
eval "$_z4h_opt"
|
eval "$_foxshell_opt"
|
||||||
-z4h-init && return
|
-foxshell-init && return
|
||||||
[[ -e $Z4H/.updating ]] || -z4h-error-command init
|
[[ -e $FOXSHELL/.updating ]] || -foxshell-error-command init
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
} always {
|
} always {
|
||||||
(( z4h_no_flock )) || setopt hist_fcntl_lock
|
(( foxshell_no_flock )) || setopt hist_fcntl_lock
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function -z4h-cmd-install() {
|
function -foxshell-cmd-install() {
|
||||||
eval "$_z4h_opt"
|
eval "$_foxshell_opt"
|
||||||
-z4h-check-core-params || return
|
-foxshell-check-core-params || return
|
||||||
|
|
||||||
local -a flush
|
local -a flush
|
||||||
zparseopts -D -F -- f=flush -flush=flush || return '_z4h_err()'
|
zparseopts -D -F -- f=flush -flush=flush || return '_foxshell_err()'
|
||||||
|
|
||||||
local invalid=("${@:#([^/]##/)##[^/]##}")
|
local invalid=("${@:#([^/]##/)##[^/]##}")
|
||||||
if (( $#invalid )); then
|
if (( $#invalid )); then
|
||||||
print -Pru2 -- '%F{3}z4h%f: %Binstall%b: invalid project name(s)'
|
print -Pru2 -- '%F{3}foxshell%f: %Binstall%b: invalid project name(s)'
|
||||||
print -Pru2 -- ''
|
print -Pru2 -- ''
|
||||||
print -Prlu2 -- ' %F{1}'${(q)^invalid//\%/%%}'%f'
|
print -Prlu2 -- ' %F{1}'${(q)^invalid//\%/%%}'%f'
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
_z4h_install_queue+=("$@")
|
_foxshell_install_queue+=("$@")
|
||||||
(( $#flush && $#_z4h_install_queue )) || return 0
|
(( $#flush && $#_foxshell_install_queue )) || return 0
|
||||||
-z4h-install-many && return
|
-foxshell-install-many && return
|
||||||
-z4h-error-command install
|
-foxshell-error-command install
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Main zsh4humans function. Type `z4h help` for usage.
|
# Main foxshell function. Type `foxshell help` for usage.
|
||||||
function z4h() {
|
function foxshell() {
|
||||||
if (( ${+functions[-z4h-cmd-${1-}]} )); then
|
if (( ${+functions[-foxshell-cmd-${1-}]} )); then
|
||||||
-z4h-cmd-"$1" "${@:2}"
|
-foxshell-cmd-"$1" "${@:2}"
|
||||||
else
|
else
|
||||||
-z4h-cmd-help >&2
|
-foxshell-cmd-help >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
[[ ${Z4H_SSH-} != <1->:* ]] || -z4h-ssh-maybe-update || return
|
[[ ${FOXSHELL_SSH-} != <1->:* ]] || -foxshell-ssh-maybe-update || return
|
||||||
|
|
||||||
unset KITTY_SHELL_INTEGRATION ITERM_INJECT_SHELL_INTEGRATION
|
unset KITTY_SHELL_INTEGRATION ITERM_INJECT_SHELL_INTEGRATION
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue