From dd07a62dc02200e3c7c3ff6b56a5703125622492 Mon Sep 17 00:00:00 2001 From: Perdixky <3293789706@qq.com> Date: Wed, 3 Dec 2025 10:04:17 +0800 Subject: [PATCH 1/4] Skip fish/conf.d when syncing to preserve user customizations --- sdata/subcmd-install/3.files-exp.yaml | 1 + sdata/subcmd-install/3.files-legacy.sh | 6 +++++- sdata/subcmd-install/3.files.sh | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/sdata/subcmd-install/3.files-exp.yaml b/sdata/subcmd-install/3.files-exp.yaml index 5282e0594..63a0cad1f 100644 --- a/sdata/subcmd-install/3.files-exp.yaml +++ b/sdata/subcmd-install/3.files-exp.yaml @@ -20,6 +20,7 @@ patterns: - from: "dots/.config/fish" to: "$XDG_CONFIG_HOME/fish" mode: "sync" + excludes: ["conf.d"] condition: type: "shell" value: "fish" diff --git a/sdata/subcmd-install/3.files-legacy.sh b/sdata/subcmd-install/3.files-legacy.sh index 6ba8cefc2..98d792be8 100644 --- a/sdata/subcmd-install/3.files-legacy.sh +++ b/sdata/subcmd-install/3.files-legacy.sh @@ -30,7 +30,11 @@ esac case "${SKIP_FISH}" in true) sleep 0;; *) - install_dir__sync dots/.config/fish "$XDG_CONFIG_HOME"/fish + # Use rsync with exclude to preserve user's custom conf.d directory + if [ -d "$XDG_CONFIG_HOME"/fish ];then + warning_overwrite + fi + rsync_dir__sync_exclude dots/.config/fish "$XDG_CONFIG_HOME"/fish "conf.d" ;; esac diff --git a/sdata/subcmd-install/3.files.sh b/sdata/subcmd-install/3.files.sh index 41e9972d0..49490a49f 100644 --- a/sdata/subcmd-install/3.files.sh +++ b/sdata/subcmd-install/3.files.sh @@ -67,6 +67,22 @@ rsync_dir__sync(){ x mkdir -p "$(dirname ${INSTALLED_LISTFILE})" rsync -a --delete --out-format='%i %n' "$1"/ "$2"/ | awk -v d="$dest" '$1 ~ /^>/{ sub(/^[^ ]+ /,""); printf d "/" $0 "\n" }' >> "${INSTALLED_LISTFILE}" } +rsync_dir__sync_exclude(){ + # NOTE: This function is only for using in other functions + # Same as rsync_dir__sync but with exclude patterns support + # Usage: rsync_dir__sync_exclude [ ...] + local src="$1" + local dest_dir="$2" + shift 2 + local excludes=() + for pattern in "$@"; do + excludes+=(--exclude "$pattern") + done + x mkdir -p "$dest_dir" + local dest="$(realpath -se $dest_dir)" + x mkdir -p "$(dirname ${INSTALLED_LISTFILE})" + rsync -a --delete "${excludes[@]}" --out-format='%i %n' "$src"/ "$dest_dir"/ | awk -v d="$dest" '$1 ~ /^>/{ sub(/^[^ ]+ /,""); printf d "/" $0 "\n" }' >> "${INSTALLED_LISTFILE}" +} function install_file(){ # NOTE: Do not add prefix `v` or `x` when using this function local s=$1 From ffd01741d9ac412525772c993cf72ceff0dcaecd Mon Sep 17 00:00:00 2001 From: Perdixky <3293789706@qq.com> Date: Wed, 3 Dec 2025 13:58:49 +0800 Subject: [PATCH 2/4] Remove repeated code --- sdata/subcmd-install/3.files.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sdata/subcmd-install/3.files.sh b/sdata/subcmd-install/3.files.sh index 49490a49f..2bd2e1190 100644 --- a/sdata/subcmd-install/3.files.sh +++ b/sdata/subcmd-install/3.files.sh @@ -62,10 +62,7 @@ rsync_dir__sync(){ # `--delete' for rsync to make sure that # original dotfiles and new ones in the SAME DIRECTORY # (eg. in ~/.config/hypr) won't be mixed together - x mkdir -p "$2" - local dest="$(realpath -se $2)" - x mkdir -p "$(dirname ${INSTALLED_LISTFILE})" - rsync -a --delete --out-format='%i %n' "$1"/ "$2"/ | awk -v d="$dest" '$1 ~ /^>/{ sub(/^[^ ]+ /,""); printf d "/" $0 "\n" }' >> "${INSTALLED_LISTFILE}" + rsync_dir__sync_exclude "$1" "$2" } rsync_dir__sync_exclude(){ # NOTE: This function is only for using in other functions From 8cfb3be4cd36689d39eafb1ae1c5cf0b067b31f4 Mon Sep 17 00:00:00 2001 From: Perdixky <3293789706@qq.com> Date: Thu, 4 Dec 2025 17:06:26 +0800 Subject: [PATCH 3/4] Use a public API to wrap rsync_* function --- sdata/subcmd-install/3.files-legacy.sh | 6 +----- sdata/subcmd-install/3.files.sh | 12 ++++++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/sdata/subcmd-install/3.files-legacy.sh b/sdata/subcmd-install/3.files-legacy.sh index 98d792be8..0a3bef85f 100644 --- a/sdata/subcmd-install/3.files-legacy.sh +++ b/sdata/subcmd-install/3.files-legacy.sh @@ -30,11 +30,7 @@ esac case "${SKIP_FISH}" in true) sleep 0;; *) - # Use rsync with exclude to preserve user's custom conf.d directory - if [ -d "$XDG_CONFIG_HOME"/fish ];then - warning_overwrite - fi - rsync_dir__sync_exclude dots/.config/fish "$XDG_CONFIG_HOME"/fish "conf.d" + install_dir__sync_exclude dots/.config/fish "$XDG_CONFIG_HOME"/fish "conf.d" ;; esac diff --git a/sdata/subcmd-install/3.files.sh b/sdata/subcmd-install/3.files.sh index 2bd2e1190..aa3099ab0 100644 --- a/sdata/subcmd-install/3.files.sh +++ b/sdata/subcmd-install/3.files.sh @@ -137,6 +137,18 @@ function install_dir__skip_existed(){ v rsync_dir $s $t fi } +function install_dir__sync_exclude(){ + # NOTE: Do not add prefix `v` or `x` when using this function + # Sync directory with exclude patterns + # Usage: install_dir__sync_exclude [ ...] + local s=$1 + local t=$2 + shift 2 + if [ -d $t ];then + warning_overwrite + fi + rsync_dir__sync_exclude $s $t "$@" +} function install_google_sans_flex(){ local font_name="Google Sans Flex" local src_name="google-sans-flex" From d83733bd8655a44ee8c2cd129a440f0de461cf77 Mon Sep 17 00:00:00 2001 From: Perdixky <3293789706@qq.com> Date: Fri, 12 Dec 2025 08:42:45 +0800 Subject: [PATCH 4/4] Restore original rsync_dir__sync() implementation --- sdata/subcmd-install/3.files.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sdata/subcmd-install/3.files.sh b/sdata/subcmd-install/3.files.sh index aa3099ab0..d0e537aa3 100644 --- a/sdata/subcmd-install/3.files.sh +++ b/sdata/subcmd-install/3.files.sh @@ -62,7 +62,10 @@ rsync_dir__sync(){ # `--delete' for rsync to make sure that # original dotfiles and new ones in the SAME DIRECTORY # (eg. in ~/.config/hypr) won't be mixed together - rsync_dir__sync_exclude "$1" "$2" + x mkdir -p "$2" + local dest="$(realpath -se $2)" + x mkdir -p "$(dirname ${INSTALLED_LISTFILE})" + rsync -a --delete --out-format='%i %n' "$1"/ "$2"/ | awk -v d="$dest" '$1 ~ /^>/{ sub(/^[^ ]+ /,""); printf d "/" $0 "\n" }' >> "${INSTALLED_LISTFILE}" } rsync_dir__sync_exclude(){ # NOTE: This function is only for using in other functions