Created
February 14, 2015 00:18
-
-
Save etcwilde/a91c876761cd50e4ef9e to your computer and use it in GitHub Desktop.
Scripts that help with vim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python | |
# Works with pathogen plugin manager for vim | |
import urllib.request | |
from subprocess import call | |
import shutil | |
from os import makedirs, path | |
# Bundles from git | |
git_bundles = [ | |
"git://github.com/derekwyatt/vim-fswitch.git", | |
] | |
# Bundles from vim site | |
# (Script_name, Script_ID, Script_type) | |
# Example of IndexedSearch | |
# ("IndexedSearch", "7062", "plugin"), | |
vim_bundles = [ | |
] | |
# delete git bundles | |
for git_bundle_url in git_bundles: | |
direc = "./bundle/" + git_bundle_url.split("/")[-1].replace('.git', "") | |
print ("Deleting {0}".format(direc)) | |
try: | |
shutil.rmtree(direc) | |
except OSError as err: | |
print ("Warning: {0}".format(err)) | |
# Delete vim bundles | |
for (name, script_id, script_type) in vim_bundles: | |
print ("Deleting {0}".format(name)) | |
direc = "./bundle/" + name | |
print ("rm -r " + direc) | |
try: | |
shutil.rmtree(direc) | |
except OSError as err: | |
print ("Warning: {0}".format(err)) | |
# Download latest version | |
for git_bundle_url in git_bundles: | |
direc = "./bundle/" + git_bundle_url.split("/")[-1].replace('.git', "") | |
print ("Unpacking {0} into {1}".format(git_bundle_url, direc)) | |
call(["git", "clone", git_bundle_url, direc]) | |
shutil.rmtree(direc + "/.git") | |
# We are downloading from git, this will always exist | |
# Download latest vim bundles | |
for (name, script_id, script_type) in vim_bundles: | |
print ("Name: {0}, ID: {1}, Type: {2}".format(name, script_id, script_type)) | |
print ("Downloading {0}".format(name)) | |
direcname = "./bundle/" + name + "/" + script_type + "/" | |
filename = direcname + name + ".vim" | |
print(direcname) | |
print(filename) | |
if not path.exists(direcname): | |
makedirs(direcname) | |
url = "http://www.vim.org/scripts/download_script.php?src_id={0}".format( | |
script_id) | |
with open(filename, "wb") as f: | |
f.write(urllib.request.urlopen(url).read()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment