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") # Skip scripts not present in target tree if not test -e $basescript continue end # Skip scripts tracked by git if git -C (path dirname $script) ls-files --error-unmatch $script &>/dev/null continue end # Skip identical scripts if cmp -s $basescript $script continue end if ask "Copy $basescript to $targetdir?" cp -f --preserve="timestamps,mode" $basescript $script end end end