From e5fac87405c6a01acc3630b0f17e7e10df858274 Mon Sep 17 00:00:00 2001 From: Deposite Pirate Date: Wed, 18 Feb 2026 05:53:37 +0100 Subject: New script to synchronise scripts This new script synchronises the fish scripts in two trees skipping the scripts not present in the target tree or those tracked by git in the target tree. new file: functions/syncscript.fish --- functions/syncscript.fish | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 functions/syncscript.fish (limited to 'functions') diff --git a/functions/syncscript.fish b/functions/syncscript.fish new file mode 100644 index 0000000..e1511cf --- /dev/null +++ b/functions/syncscript.fish @@ -0,0 +1,29 @@ +function syncscript --description "Synchronise fish script between two \ + directories trees" -a basedir -a targetdir + +if test (count $argv) -lt 2 + echo "Missing arguments." + return 1 +end + +set -f fishscriptdirs '/.config/fish/' + +for script in (find $targetdir -type f -path "*$fishscriptdirs*/*" -name "*.fish") + + set -l basescript (string replace "$targetdir" "$basedir" "$script") + + if not test -e $basescript + continue + end + + if git -C (path dirname $script) ls-files --error-unmatch $script &>/dev/null + continue + end + + if ask "Copy $basescript to $targetdir?" + cp -f --preserve="timestamps,mode" $basescript $script + end + +end + +end -- cgit v1.3.1