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