From 93755bfc0abe433c71941e14c3aea6e3a4993d51 Mon Sep 17 00:00:00 2001 From: "Lockszmith (@VAST)" Date: Thu, 10 Apr 2025 11:16:08 -0400 Subject: [PATCH 1/7] replace chezmoi pager to moar --- _src.all/.chezmoi.toml.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_src.all/.chezmoi.toml.tmpl b/_src.all/.chezmoi.toml.tmpl index bb171eb..8c778df 100644 --- a/_src.all/.chezmoi.toml.tmpl +++ b/_src.all/.chezmoi.toml.tmpl @@ -93,5 +93,5 @@ scriptTempDir={{- $scriptTempDir | quote }} command = "delta" args = ["--paging=never", "{{ "{{ .Destination }}" }}", "{{ "{{ .Target }}" }}"] - pager = "delta" + pager = "moar" From 491bc65261486232b6cc449d79c2e111f9ca29e3 Mon Sep 17 00:00:00 2001 From: "Lockszmith (@VAST)" Date: Thu, 10 Apr 2025 11:16:26 -0400 Subject: [PATCH 2/7] Correctly cleanup zellij on MacOS --- .../private_dot_local/bin/executable_load-zellij | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/_src.posix/private_dot_local/bin/executable_load-zellij b/_src.posix/private_dot_local/bin/executable_load-zellij index 7b10c37..cddffd7 100644 --- a/_src.posix/private_dot_local/bin/executable_load-zellij +++ b/_src.posix/private_dot_local/bin/executable_load-zellij @@ -15,14 +15,17 @@ BASE_SHELL="${BASE_SHELL:-$(basename "$SHELL")}" if is_sourced; then zellij-cleanup() { - env which zellij > /dev/null && env which zellij | grep -E "^$HOME" | ${SUDO:-} xargs -tr rm - [[ -d "$HOME/.cache/zellij" ]] && echo "$HOME/.cache/zellij" | ${SUDO:-} xargs -tr rm -fR + env which zellij > /dev/null && command -v zellij | grep -E "^$HOME" | ${SUDO:-} xargs -tr rm + [[ -d "$HOME/.cache/zellij" ]] \ + && ${SUDO:-} rm -fR "$HOME/.cache/zellij" + [[ -d "$HOME/Library/Caches/org.Zellij-Contributors.Zellij" ]] \ + && ${SUDO:-} rm -fR "$HOME/Library/Caches/org.Zellij-Contributors.Zellij" find /tmp -maxdepth 1 -mindepth 1 -type d -name 'zellij*' -print0 | ${SUDO:-} xargs -r0t rm -fR - if [[ -d "$HOME/.cache/zellij" ]]; then + if [[ -d "$HOME/.cache/zellij" || -d "$HOME/Library/Caches/org.Zellij-Contributors.Zellij" ]]; then printf 'Zellij cleanup failed to remove the cache directory, you might still have a zellij session active.\n' else printf 'Zellij has been cleaned up, you can now reinstall it.\n' - unset zellij-cleanup + unset -f zellij-cleanup fi } refresh-zellij() { From 39b089268e899f5ee3db289e116865deea600a46 Mon Sep 17 00:00:00 2001 From: "Lockszmith (@VAST)" Date: Thu, 10 Apr 2025 11:16:55 -0400 Subject: [PATCH 3/7] fix czcd bug introduced in previous commit --- _src.posix/private_dot_config/sz.env/zzz_chezmoi.env.tmpl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/_src.posix/private_dot_config/sz.env/zzz_chezmoi.env.tmpl b/_src.posix/private_dot_config/sz.env/zzz_chezmoi.env.tmpl index 89f6281..f90b3bc 100644 --- a/_src.posix/private_dot_config/sz.env/zzz_chezmoi.env.tmpl +++ b/_src.posix/private_dot_config/sz.env/zzz_chezmoi.env.tmpl @@ -16,9 +16,9 @@ if is_cmd 'chezmoi'; then chezmoi() { ${SET_X:-:} -x case "$1" in - "cd") cd "$(chezmoi source-path "${@:2}")" ;; - "edit") ${VISUAL:-${EDITOR:-vi}} $(chezmoi source-path "${@:2}") ;; - "source-path") printf '%s\n' "${@:2}" | xargs -r chezmoi source-path ;; + cd) cd "$(SET_X=':' command chezmoi source-path ${2})" ;; + edit) ${VISUAL:-${EDITOR:-vi}} $(SET_X=':' chezmoi source-path "${@:2}") ;; + source-path) printf '%s\n' "${@:2}" | xargs -r chezmoi source-path ;; *) command chezmoi "${@}" ;; esac ${SET_X:-:} +x From d29a237c665fef4a3b52ce99d1d97d96e698e91c Mon Sep 17 00:00:00 2001 From: "Lockszmith (Mac@VAST)" Date: Thu, 10 Apr 2025 11:30:55 -0400 Subject: [PATCH 4/7] Added backup on first time apply - in case reverting is wanted --- .chezmoiscripts/run_init.sh.tmpl | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.chezmoiscripts/run_init.sh.tmpl b/.chezmoiscripts/run_init.sh.tmpl index d74d340..6b4a24d 100755 --- a/.chezmoiscripts/run_init.sh.tmpl +++ b/.chezmoiscripts/run_init.sh.tmpl @@ -19,5 +19,34 @@ else false fi +# Function to get relative path without realpath or python +relpath() { + local target=$1 + local base=$2 + local target_abs=$(cd "$(dirname "$target")" && pwd)/$(basename "$target") + local base_abs=$(cd "$base" && pwd) + local common_part="$base_abs" + local back="" + + while [[ "${target_abs#$common_part}" == "$target_abs" ]]; do + common_part=$(dirname "$common_part") + back="../$back" + done + + echo "${back}${target_abs#$common_part/}" +} + +safe_backup() { + local BASE="${BASE:-$HOME/.cache/chezmoi/init_backup}" + while [ -n "${1}" ]; do + local relp="./$(relpath "${1}" ~)" + [ -r "${1}" ] && mkdir -p "${BASE}/${relp%/*}" && cp ${CPOPTS:-} "${1}" "${BASE}/${relp}" + shift + done +} +if ! [ -d ~/.cache/chezmoi/init_backup ]; then + safe_backup ~/.zshrc ~/.zsh_history ~/.zprofile ~/.bashrc ~/.bash_history ~/.profile +fi + # Brute force remove chezmoistate lock and restart init --apply exec sh -c 'rm ~/.config/chezmoi/chezmoistate.boltdb && chezmoi init --apply' From cc0451d7db21ca5f3879924ca09007ad1bf2d804 Mon Sep 17 00:00:00 2001 From: "Lockszmith (Mac@VAST)" Date: Thu, 10 Apr 2025 12:24:30 -0400 Subject: [PATCH 5/7] download externals when first initializing --- .chezmoiscripts/run_init.sh.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.chezmoiscripts/run_init.sh.tmpl b/.chezmoiscripts/run_init.sh.tmpl index 6b4a24d..c43cb41 100755 --- a/.chezmoiscripts/run_init.sh.tmpl +++ b/.chezmoiscripts/run_init.sh.tmpl @@ -49,4 +49,4 @@ if ! [ -d ~/.cache/chezmoi/init_backup ]; then fi # Brute force remove chezmoistate lock and restart init --apply -exec sh -c 'rm ~/.config/chezmoi/chezmoistate.boltdb && chezmoi init --apply' +exec sh -c 'rm ~/.config/chezmoi/chezmoistate.boltdb && CZ_EXTR=1 chezmoi init --apply' From af74c92abb0fa6fada85367c8db992c83ad9d4b1 Mon Sep 17 00:00:00 2001 From: "Lockszmith (Mac@VAST)" Date: Thu, 10 Apr 2025 12:25:58 -0400 Subject: [PATCH 6/7] fixed cargo-binsall url based externals --- _src.posix/.chezmoiexternal.yaml.tmpl | 44 +++++++++++++-------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/_src.posix/.chezmoiexternal.yaml.tmpl b/_src.posix/.chezmoiexternal.yaml.tmpl index 34411ff..87cd982 100644 --- a/_src.posix/.chezmoiexternal.yaml.tmpl +++ b/_src.posix/.chezmoiexternal.yaml.tmpl @@ -99,23 +99,8 @@ "refreshPeriod" $defaultRefresh ) -}}{{- end -}}{{- end -}}{{- end -}} -{{- if (eq .chezmoi.os "linux") -}} -{{- with $app_name := "vivid" -}} -{{- with $repo := (printf "%s/%s" "sharkdp" $app_name) -}} -{{- with $version := (gitHubLatestRelease $repo).GetTagName -}} -{{- $_ := set $externals (printf ".local/bin/%s" $app_name) (dict - "type" "archive-file" - "url" (printf "https://github.com/%s/releases/download/%s/%s-%s-%s.tar.gz" $repo $version $app_name $version $myArch) - "path" (printf "%s-%s-%s/%s" $app_name $version $myArch $app_name) - "executable" true - "refreshPeriod" $defaultRefresh -) -}}{{- end -}}{{- end -}}{{- end -}} -{{- end -}}{{/* if linux */}} - -{{ $myArch = (printf "%s-%s" .sz.os.arch_alt "unknown-linux-gnu" )}} - {{- with $app_name := "eza" -}} -{{- with $cargo_bin_url := (output "sh" "-c" ( +{{- with $bin_url := (output "sh" "-c" ( list "cargo-binstall --log-level debug --dry-run --no-track --no-confirm --json-output" $app_name @@ -126,12 +111,30 @@ {{- with $repo := (printf "%s/%s" "eza-community" $app_name) -}} {{- $_ := set $externals (printf ".local/bin/%s" $app_name) (dict "type" "archive-file" - "url" $cargo_bin_url + "url" $bin_url "path" $app_name "executable" true "refreshPeriod" $defaultRefresh ) -}}{{- end -}}{{- end -}}{{- end -}} +{{- with $app_name := "vivid" -}} +{{- with $bin_url := (output "sh" "-c" ( + list + "cargo-binstall --log-level debug --dry-run --no-track --no-confirm --json-output" + $app_name + "| jq \".fields | select ( .message == \\\"Downloading package\\\" )\"" + | join " ") | fromJson + ).url +-}} +{{- with $path := trimSuffix ".zip" (trimSuffix ".tgz" (trimSuffix ".tar" (trimSuffix ".gz" (base $bin_url)))) -}} +{{- $_ := set $externals (printf ".local/bin/%s" $app_name) (dict + "type" "archive-file" + "url" $bin_url + "path" (printf "%s/%s" $path $app_name) + "executable" true + "refreshPeriod" $defaultRefresh +) -}}{{- end -}}{{- end -}}{{- end -}} + {{/* # valid arch strings: # darwin_amd64 @@ -178,10 +181,7 @@ # win */}} -{{- $myArch = .sz.os.short -}} -{{- if eq .chezmoi.os "linux" -}} -{{- $myArch = (printf "%s-%s" .chezmoi.os .sz.os.arch_alt) -}} -{{- end -}} +{{- $myArch := or (get (dict "linux" (printf "%s-%s" .chezmoi.os .sz.os.arch_alt)) .chezmoi.os) .sz.os.short }} {{- with $app_name := "gitui" -}} {{- with $repo := (printf "%s/%s" "extrawurst" $app_name) -}} @@ -194,7 +194,6 @@ "refreshPeriod" $defaultRefresh ) -}}{{- end -}}{{- end -}}{{- end -}} - {{/* # valid arch strings: # darwin-amd64 @@ -321,3 +320,4 @@ executable: true refreshPeriod: "{{ $defaultRefresh }}" {{- end -}} + From c77e0d9bec1d98a6f8ea1b9c0e6128c437f7a788 Mon Sep 17 00:00:00 2001 From: "Lockszmith (Mac@VAST)" Date: Thu, 10 Apr 2025 12:27:16 -0400 Subject: [PATCH 7/7] fix bug in czedext introduced by latest chezmoi function changes --- _src.posix/private_dot_config/sz.env/zzz_chezmoi.env.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_src.posix/private_dot_config/sz.env/zzz_chezmoi.env.tmpl b/_src.posix/private_dot_config/sz.env/zzz_chezmoi.env.tmpl index f90b3bc..f8bdcac 100644 --- a/_src.posix/private_dot_config/sz.env/zzz_chezmoi.env.tmpl +++ b/_src.posix/private_dot_config/sz.env/zzz_chezmoi.env.tmpl @@ -25,7 +25,7 @@ if is_cmd 'chezmoi'; then } czcd() { chezmoi cd "${@}"; } czedext() { - local CZ_EXT="$(find $(chezmoi source-path) -mindepth 1 -maxdepth 1 -name '.chezmoiexternal.*')" + local CZ_EXT="$(find $(command chezmoi source-path) -mindepth 1 -maxdepth 1 -name '.chezmoiexternal.*')" CZ_EXT="${CZ_EXT:-$(chezmoi source-path "${@}")/.chezmoiexternal.yaml.tmpl}" "${VISUAL:-${EDITOR:-vi}}" "${CZ_EXT}" }