Compare commits
7 commits
dc1b0b0761
...
c77e0d9bec
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c77e0d9bec | ||
![]() |
af74c92abb | ||
![]() |
cc0451d7db | ||
![]() |
d29a237c66 | ||
![]() |
39b089268e | ||
![]() |
491bc65261 | ||
![]() |
93755bfc0a |
5 changed files with 64 additions and 32 deletions
|
@ -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'
|
||||
exec sh -c 'rm ~/.config/chezmoi/chezmoistate.boltdb && CZ_EXTR=1 chezmoi init --apply'
|
||||
|
|
|
@ -93,5 +93,5 @@ scriptTempDir={{- $scriptTempDir | quote }}
|
|||
|
||||
command = "delta"
|
||||
args = ["--paging=never", "{{ "{{ .Destination }}" }}", "{{ "{{ .Target }}" }}"]
|
||||
pager = "delta"
|
||||
pager = "moar"
|
||||
|
||||
|
|
|
@ -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 -}}
|
||||
|
||||
|
|
|
@ -16,16 +16,16 @@ 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
|
||||
}
|
||||
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}"
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue