]> Sergey Matveev's repositories - nnn.git/commitdiff
Bind getplugs to installed version
authorArun Prakash Jana <engineerarun@gmail.com>
Sun, 3 May 2020 14:56:06 +0000 (20:26 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sun, 3 May 2020 14:58:16 +0000 (20:28 +0530)
plugins/README.md
plugins/getplugs

index dbd0e9ea174f098cc016b49bb8d17f8cbc114dca..e8f8958519b5339c53dce613c11fbc844acaa6c0 100644 (file)
@@ -37,7 +37,7 @@ Plugins are installed to `${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins`.
 | fzhist | Fuzzy-select a cmd from history, edit in `$EDITOR` and run | sh | fzf/fzy |
 | fzopen | Fuzzy find a file in dir subtree and edit or open | sh | fzf/fzy, xdg-open |
 | fzz | Change to any directory in the z database with fzf/fzy | sh | fzf/fzy, z |
-| getplugs | Update plugins | sh | curl |
+| getplugs | Update plugins to installed `nnn` version | sh | curl |
 | gutenread | Browse, download, read from Project Gutenberg | sh | curl, unzip, w3m<br>[epr](https://github.com/wustho/epr) (optional) |
 | hexview | View a file in hex in `$PAGER` | sh | xxd |
 | imgresize | Resize images in dir to screen resolution | sh | [imgp](https://github.com/jarun/imgp) |
index 5cda1aba5f7d3f70d821e914c7ce51a4ef9cd6f2..2dfc00276c8616f7c0cfa2e9e7272eae8e480589 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env sh
 
-# Description: Update nnn plugins
+# Description: Update nnn plugins to installed nnn version
 #
 # Shell: POSIX compliant
 # Author: Arun Prakash Jana, KlzXS
@@ -43,6 +43,13 @@ prompt () {
 #     sucmd=: # noop
 # fi
 
+if which nnn >/dev/null 2>&1; then
+    VER=$(nnn -V)
+else
+    echo "nnn is not installed"
+    exit 1
+fi
+
 # backup any earlier plugins
 if [ -d "$PLUGIN_DIR" ]; then
     tar -C "$CONFIG_DIR" -czf "$CONFIG_DIR""plugins-$(date '+%Y%m%d%H%M').tar.gz" plugins/
@@ -50,10 +57,10 @@ fi
 
 mkdir -p "$PLUGIN_DIR"
 cd "$CONFIG_DIR" || exit 1
-curl -Ls -O https://github.com/jarun/nnn/archive/master.tar.gz
-tar -zxf master.tar.gz
+curl -Ls -O https://github.com/jarun/nnn/releases/download/v"$VER"/nnn-v"$VER".tar.gz
+tar -zxf nnn-v"$VER".tar.gz
 
-cd nnn-master/plugins || exit 1
+cd nnn-"$VER"/plugins || exit 1
 
 # shellcheck disable=SC2044
 # We do not use obnoxious names for plugins
@@ -69,4 +76,4 @@ for f in $(find . -maxdepth 1 \( ! -iname "." ! -iname "*.md" \)); do
 done
 cd ../.. || exit 1
 
-rm -rf nnn-master/ master.tar.gz
+rm -rf nnn-"$VER"/ nnn-v"$VER".tar.gz