diff options
author | KlzXS <azszwymmvqdi@yahoo.com> | 2019-11-17 15:22:36 +0100 |
---|---|---|
committer | Mischievous Meerkat <engineerarun@gmail.com> | 2019-11-17 19:52:36 +0530 |
commit | 2cbd76abf6ecadec68fc8c61e3e21c4f2c3d17da (patch) | |
tree | c524aeaf85123b460622f594266836876c68999b | |
parent | 0f5f04d087f886e3c732975afa3dd69bbcfc625a (diff) | |
download | nnn-2cbd76abf6ecadec68fc8c61e3e21c4f2c3d17da.tar.gz |
getpulgs now asks before overwriting (#385)
* getpulgs now asks before overwriting
* Forgot a space
-rwxr-xr-x | plugins/getplugs | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/plugins/getplugs b/plugins/getplugs index b7fa67d..e6d235f 100755 --- a/plugins/getplugs +++ b/plugins/getplugs @@ -13,6 +13,25 @@ is_cmd_exists () { echo $? } +merge () { + vimdiff $1 $2 + cp -vRf $1 $2 +} + +prompt () { + echo "Plugin $1 already exists and is different." + echo -n "Keep (k), merge (m), overwrite (o) [default: k]? " + read operation + + if [ "$operation" = "m" ]; then + op="merge" + elif [ "$operation" = "o" ]; then + op="cp -vRf" + else + op="true" + fi +} + if [ "$(is_cmd_exists sudo)" -eq "0" ]; then sucmd=sudo elif [ "$(is_cmd_exists doas)" -eq "0" ]; then @@ -29,6 +48,19 @@ fi cd $CONFIG_DIR curl -Ls -O https://github.com/jarun/nnn/archive/master.tar.gz tar -zxf master.tar.gz -cp -vRf nnn-master/plugins . + +cd nnn-master/plugins +for f in *; do + if [ -f ../../plugins/$f ]; then + if [ "$(diff --brief $f ../../plugins/$f)" ]; then + prompt $f + $op $f ../../plugins/ + fi + else + cp -vRf $f ../../plugins/ + fi +done +cd ../.. + $sucmd mv -vf nnn-master/misc/nlaunch/nlaunch /usr/local/bin/ rm -rf nnn-master/ master.tar.gz README.md |