diff options
2 files changed, 13 insertions, 27 deletions
| -rwxr-xr-x | copy.sh | 24 | ||||
| -rwxr-xr-x | install.sh | 16 |
diff --git a/copy.sh b/copy.sh deleted file mode 100755 index c07f01f..0000000 --- a/copy.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -while read -r conf -do - [ -z "$conf" ] && continue - [ ! -f "$conf" ] && echo "warning: $conf is not a regular file, skipping!" && continue - - dest="$HOME/$conf" - if [ -f "$dest" ] && ! cmp --silent -- "$dest" "$conf" - then - diff "$dest" "$conf" - printf "Files $dest and $conf are not the same! Overwrite? [y/N] " - read -n1 overwrite </dev/tty - echo - [ "$overwrite" != 'y' && "$overwrite" != 'Y' ] && continue - fi - - dir="$(dirname "$dest")" - [ ! -d "$dir" ] && mkdir -p "$dir" || rm "$dest" >/dev/null 2>&1 - cp "$PWD/$conf" "$dest" - echo "Installed ${conf##\./}" -done <<EOF -$(find . -type f -not -path './.git/*' -not -name 'README.md' -not -name 'install.sh' -not -name 'copy.sh') -EOF @@ -1,11 +1,20 @@ #!/usr/bin/env bash +copy="" +while [ -n "$1" ] +do + case "$1" in + (cp | copy) copy="yes" ;; + esac + shift +done + while read -r conf do [ -z "$conf" ] && continue [ ! -f "$conf" ] && echo "warning: $conf is not a regular file, skipping!" && continue - dest="$HOME/$conf" + dest="$HOME/${conf##\./}" if [ -f "$dest" ] && ! cmp --silent -- "$dest" "$conf" then diff "$dest" "$conf" @@ -17,8 +26,9 @@ do dir="$(dirname "$dest")" [ ! -d "$dir" ] && mkdir -p "$dir" || rm "$dest" >/dev/null 2>&1 - ln -s "$PWD/$conf" "$dest" + + [ -n "$copy" ] && cp "$PWD/$conf" "$dest" || ln -s "$PWD/$conf" "$dest" echo "Installed ${conf##\./}" done <<EOF -$(find . -type f -not -path './.git/*' -not -name 'README.md' -not -name 'install.sh' -not -name 'copy.sh') +$(find . -type f -not -path './.git/*' -not -name 'README.md' -not -name 'install.sh') EOF |
