From 4f030a35efab96334abc183b55cccea7ed19e54d Mon Sep 17 00:00:00 2001 From: Gustavo Cordova Date: Fri, 4 Jun 2021 12:13:19 -0700 Subject: [PATCH] Add scripts to save/reload/update current state --- bundle/bundles.sh | 54 ++++++++++++++++++++++++++++++++++++++++++++++ bundle/bundles.txt | 11 ++++++++++ 2 files changed, 65 insertions(+) create mode 100755 bundle/bundles.sh create mode 100644 bundle/bundles.txt diff --git a/bundle/bundles.sh b/bundle/bundles.sh new file mode 100755 index 0000000..672f69c --- /dev/null +++ b/bundle/bundles.sh @@ -0,0 +1,54 @@ +#!/bin/bash +usage() { + cat << EOT +Usage: + ./${0##*/} list|update|clone|save + +Commands: + ls -> List all the bundle repos + update -> Update all the bundle repos + clone -> Use 'bundles.txt' to repopulate + save -> Save repos to 'bundles.txt' +EOT + exit +} + +colors() { + sed -E -e 's/\[red\]//g' \ + -e 's/\[green\]//g' \ + -e 's/\[reset\]//g' \ + -e 's/\[b\]//g' \ + -e 's/\[ul\]//g' +} + +repos() { + # Eval "$1" for all directories + local dn + for dn in * ; do + [[ -d "$dn" ]] || continue + eval "${1//@@/$dn}" | colors + done +} + +clone_bundles() { + # Clone the bundles in 'bundles.txt' + locals dn repo + while read -r dn repo ; do + if [[ -d "$dn" ]]; then + echo "*** Dir [red][$dn][reset] already exists!" | colors + else + git clone "$repo" "$dn" 2>&1 | sed "s|^|[green][$dn][reset] |g" | colors + fi + done < bundles.txt +} + +case "$1" in + ls) repos 'echo -e "[red]@@[reset] [green]$(git -C @@ remote get-url origin)[reset]"' ;; + update) repos 'git -C @@ pull 2>&1 | sed "s|^|[@@] |g"' ;; + save) repos 'echo -e "@@ $(git -C @@ remote get-url origin)"' | tee bundles.txt ;; + clone) clone_bundles ;; + ?*) echo "Unknown command: $1" ;; + *) usage ;; +esac + +# Fin. diff --git a/bundle/bundles.txt b/bundle/bundles.txt new file mode 100644 index 0000000..feb8c96 --- /dev/null +++ b/bundle/bundles.txt @@ -0,0 +1,11 @@ +dockerfile git@github.com:ekalinin/Dockerfile.vim.git +fugitive git@github.com:tpope/vim-fugitive.git +nerdtree git@github.com:preservim/nerdtree.git +nerdtree-git git@github.com:Xuyuanp/nerdtree-git-plugin.git +nim git@github.com:zah/nim.vim.git +solarized git@github.com:altercation/vim-colors-solarized.git +syntastic git@github.com:vim-syntastic/syntastic.git +terraform git@github.com:hashivim/vim-terraform.git +terragrunt https://github.com/yorinasub17/vim-terragrunt.git +toml https://github.com/cespare/vim-toml.git +zig git@github.com:ziglang/zig.vim.git