From 01663576b57e969e72c3f1dfa3211b555604c616 Mon Sep 17 00:00:00 2001 From: Christopher Beckmann Date: Sat, 27 May 2023 21:05:39 +0200 Subject: [PATCH] Update 'kfg' --- kfg | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/kfg b/kfg index 7a57efa..f78397f 100644 --- a/kfg +++ b/kfg @@ -328,6 +328,30 @@ function github_install { } +function github_download_config { + ensure get_architecture + local _program=$1 + local _arch="${RETVAL}" + local _repo=$2 + local _url="https://api.github.com/repos/$_repo/releases/latest" + local _file=$3 + + assert_nz "${_arch}" "arch" + + need_cmd grep + + download "${_url}" + local _releases=$RETVAL + + (echo "${_releases}" | grep -q 'API rate limit exceeded') && (log_error "GitHub API rate limit exceeded. Please try again later." || return 1) + + local _tag_name _remote_file _path + _tag_name="$(echo "${_releases}" | grep "tag_name" | cut -d '"' -f 4)" + _remote_file="https://raw.githubusercontent.com/$_repo/$_tag_name/$_file" + + download_config "$_program" "$_file" "$_remote_file" +} + function install_deb_check { CHECK_CURRENT=$(dpkg -s "$1" | grep -E "Status|Version") #INSTALLED_CURRENT=$(echo $CHECK_CURRENT | grep -oE "Status: .*" | cut -d ' ' -f 2) @@ -586,6 +610,8 @@ function p_fzf { fi install_rc_download fzf "fzf.rc" "https://git.cbeck.tech/kamu/dotfiles/raw/branch/main/.config/fzf/fzf.rc" + github_download_config "fzf" "$_repo" "shell/completion.zsh" + github_download_config "fzf" "$_repo" "shell/key-bindings.zsh" } function p_fzf_tab {