first commit
This commit is contained in:
commit
0610f4aeab
130 changed files with 9897 additions and 0 deletions
59
fn/-z4h-postinstall-fzf
Normal file
59
fn/-z4h-postinstall-fzf
Normal file
|
@ -0,0 +1,59 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
eval "$_z4h_opt"
|
||||
|
||||
if [[ -e $Z4H/.updating ]]; then
|
||||
print -ru2 -- ${(%):-"%F{3}z4h%f: updating %Bfzf%b binary"}
|
||||
else
|
||||
print -ru2 -- ${(%):-"%F{3}z4h%f: fetching %Bfzf%b binary"}
|
||||
fi
|
||||
|
||||
local uname_sm
|
||||
[[ ! -v commands[uname] ]] || uname_sm=$(uname -sm) || return
|
||||
|
||||
local -i installed
|
||||
|
||||
case $uname_sm in
|
||||
'Darwin arm64')
|
||||
local v=0.25.1
|
||||
local url=https://github.com/zsh4humans/fzf/releases/download/$v/fzf-$v-darwin_arm8.tar.gz
|
||||
;;
|
||||
'Linux i686')
|
||||
local v=0.22.0
|
||||
local url=https://github.com/junegunn/fzf-bin/releases/download/$v/fzf-$v-linux_386.tgz
|
||||
;;
|
||||
*)
|
||||
local BASH_SOURCE=($Z4H_PACKAGE_DIR/install) err
|
||||
if ! err=$(local opt && emulate sh && set -- --bin &&
|
||||
builtin source "${BASH_SOURCE[0]}" 2>&1); then
|
||||
print -ru2 -- $err
|
||||
return 1
|
||||
fi
|
||||
installed=1
|
||||
;;
|
||||
esac
|
||||
|
||||
if (( ! installed )); then
|
||||
local err archive=$Z4H_PACKAGE_DIR/fzf.tar.gz
|
||||
if (( $+commands[curl] )); then
|
||||
err="$(command curl -fsSL -- $url 2>&1 >$archive)"
|
||||
elif (( $+commands[wget] )); then
|
||||
err="$(command wget -O- -- $url 2>&1 >$archive)"
|
||||
else
|
||||
print -Pru2 -- "%F{3}z4h%f: please install %F{1}curl%f or %F{1}wget%f"
|
||||
return 1
|
||||
fi
|
||||
if (( $? )); then
|
||||
print -ru2 -- $err
|
||||
print -Pru2 -- "%F{3}z4h%f: failed to download %F{1}${url//\%/%%}%f"
|
||||
return 1
|
||||
fi
|
||||
[[ -e $Z4H_PACKAGE_DIR/bin ]] || zf_mkdir -- $Z4H_PACKAGE_DIR/bin || return
|
||||
command tar -C $Z4H_PACKAGE_DIR/bin -xzf $archive || return
|
||||
zf_rm -- $archive || return
|
||||
fi
|
||||
|
||||
if [[ -h $Z4H_PACKAGE_DIR/bin/fzf ]]; then
|
||||
command cp -- $Z4H_PACKAGE_DIR/bin/fzf $Z4H_PACKAGE_DIR/bin/fzf.tmp || return
|
||||
zf_mv -f -- $Z4H_PACKAGE_DIR/bin/fzf.tmp $Z4H_PACKAGE_DIR/bin/fzf || return
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue