Kaynağa Gözat

Add a shell function to update/download vim scripts.

Emmanuel Bouthenot 14 yıl önce
ebeveyn
işleme
7ccce76267
1 değiştirilmiş dosya ile 46 ekleme ve 0 silme
  1. 46 0
      .zsh.d/config.d/vim-scripts.zsh

+ 46 - 0
.zsh.d/config.d/vim-scripts.zsh

@@ -0,0 +1,46 @@
+#!/bin/zsh
+
+#
+# Vim scripts updates
+#
+
+set -A vim_scripts \
+    "https://github.com/Jonty/phplint.vim/raw/master/phplint.vim" \
+    "http://git.openics.org/cgit.cgi/bindzoneedit.vim/plain/bindzoneedit.vim"
+
+vim_scripts_update() {
+    local ret=0
+
+    if which wget &>/dev/null; then
+        for i in {1..${#vim_scripts}} ; do
+            local script=$vim_scripts[$i]
+            local script_name=$(basename "$script")
+            local script_path=${HOME}/.vim/plugin/${script_name}
+            local script_path_temp=${script_path}.new
+
+            echo -n "Upgrading “${script_name}” from $script ...  "
+            echo "\"" > "${script_path_temp}"
+            echo "\" script downloaded from ${script}" >> "${script_path_temp}"
+            echo "\"" >> "${script_path_temp}"
+            echo "" >> "${script_path_temp}"
+            wget --no-check-certificate -q "$script" -O - >> "${script_path_temp}"
+            if [ $? = 0 ]; then
+                if [ -r "${script_path}" ]; then
+                    rm -f "${script_path}"
+                fi
+                mv "${script_path_temp}" "${script_path}"
+                echo "done"
+            else
+                echo "fail"
+                ret=1
+            fi
+            rm -f "${script_path_temp}"
+        done
+    else
+        echo "Can't find “wget” (not in path or installed?)."
+        ret=1
+    fi
+
+    return ret
+}
+