From e9301b2f9bee3d9bb6354fe58578654fd21ff548 Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Wed, 2 Oct 2019 14:57:54 +0200 Subject: Redo vimbundle into gittab --- .gitignore | 5 ++- .local/bin/gittab | 87 ++++++++++++++++++++++++++++++++++++++++++ .local/bin/vimbundle | 23 ----------- .local/etc/gittab/basedirs | 1 + .local/etc/gittab/tabs/awesome | 0 .local/etc/gittab/tabs/vim | 14 +++++++ .vim/bundletab | 14 ------- 7 files changed, 106 insertions(+), 38 deletions(-) create mode 100755 .local/bin/gittab delete mode 100755 .local/bin/vimbundle create mode 100644 .local/etc/gittab/basedirs create mode 100644 .local/etc/gittab/tabs/awesome create mode 100644 .local/etc/gittab/tabs/vim delete mode 100644 .vim/bundletab diff --git a/.gitignore b/.gitignore index 9612266..e21b321 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,7 @@ /.local/* !/.local/bin /.local/bin/* -!/.local/bin/vimbundle +!/.local/bin/gittab +!/.local/etc +/.local/etc/* +!/.local/etc/gittab diff --git a/.local/bin/gittab b/.local/bin/gittab new file mode 100755 index 0000000..1877ac2 --- /dev/null +++ b/.local/bin/gittab @@ -0,0 +1,87 @@ +#! /usr/bin/env perl6 + +use v6.d; + +constant TABDIR = $*HOME.add('.local/etc/gittab/tabs'); +constant TABCONF = $*HOME.add('.local/etc/gittab/basedirs'); + +#| Update managed git repositories +multi sub MAIN ( + #| A list of targets to update. + *@targets, +) { + @targets = TABDIR.dir.map(*.basename) unless @targets; + + for @targets -> $target { + my $tab = find-tab($target); + + note "No gittab for target '$target'" unless $tab; + + my $basedir = get-basedir($target); + + mkdir($basedir) unless $basedir.d; + + for $tab.lines.grep(!*.starts-with("#")) { + my ($name, $repo, $branch) = $_.words; + + if (!$basedir.add($name).d) { + chdir $basedir; + run « git clone --single-branch --branch "$branch" --depth 1 "$repo" "$name" »; + } + + chdir $basedir.add($name); + run « git switch "$branch" »; + run « git pull origin "$branch" »; + } + } +} + +#| List managed git repositories +multi sub MAIN ( + Bool:D :$list!, +) { + my @tabs = TABDIR.dir.map(*.basename).sort; + my $longest = @tabs.map(*.chars).sort.tail; + + for @tabs { + "%-{$longest}s %s\n".printf($_, get-basedir($_)); + } +} + +sub find-tab ( + Str:D $name, +) { + my @attempts = + $name, + $name ~ 'tab', + ; + + for @attempts { + my $fh = TABDIR.add($_); + + return $fh if $fh.f; + } + + Nil; +} + +sub get-basedir ( + Str:D $tab, +) { + state %basedirs; + + if (!%basedirs && TABCONF.e) { + TABCONF + .lines + .grep(!*.starts-with('#')) + .map({ + my ($tab, $basedir) = $_.words; + + %basedirs{$tab} = $basedir.IO; + }) + } + + return $*HOME unless %basedirs{$tab}:exists; + + $*HOME.add(%basedirs{$tab}); +} diff --git a/.local/bin/vimbundle b/.local/bin/vimbundle deleted file mode 100755 index 27406fe..0000000 --- a/.local/bin/vimbundle +++ /dev/null @@ -1,23 +0,0 @@ -#! /usr/bin/env perl6 - -#| Update installed bundles for vim. -sub MAIN () -{ - my $bundletab = $*HOME.add(".vim/bundletab"); - my $bundledir = $*HOME.add(".vim/bundle"); - - die "No bundletab!" unless $bundletab.e; - - for $bundletab.lines.grep(!*.starts-with("#")) { - my ($name, $repo, $branch) = $_.words; - - if (!$bundledir.add($name).d) { - chdir $bundledir; - run « git clone --single-branch --branch "$branch" --depth 1 "$repo" "$name" »; - } - - chdir $bundledir.add($name); - run « git switch "$branch" »; - run « git pull origin "$branch" »; - } -} diff --git a/.local/etc/gittab/basedirs b/.local/etc/gittab/basedirs new file mode 100644 index 0000000..bc0ee14 --- /dev/null +++ b/.local/etc/gittab/basedirs @@ -0,0 +1 @@ +vim .vim/bundle diff --git a/.local/etc/gittab/tabs/awesome b/.local/etc/gittab/tabs/awesome new file mode 100644 index 0000000..e69de29 diff --git a/.local/etc/gittab/tabs/vim b/.local/etc/gittab/tabs/vim new file mode 100644 index 0000000..a2b9c21 --- /dev/null +++ b/.local/etc/gittab/tabs/vim @@ -0,0 +1,14 @@ +# $HOME/.vim/bundletab +# +# This file contains a table of vim plugins that are to be installed in the +# $HOME/.vim/bundle directory. Pathogen will load these as needed. +# +# Local name Remote URL Branch +# +feature-camelcasemotion https://github.com/tyil/camelcasemotion.git master +syntax-helm https://github.com/towolf/vim-helm master +syntax-perl6 https://github.com/vim-perl/vim-perl6.git master +syntax-terraform https://github.com/hashivim/vim-terraform master +theme-colorsbox https://github.com/mkarmona/colorsbox.git master +theme-jellybeans https://github.com/nanotech/jellybeans.vim.git master +theme-molokai https://github.com/tomasr/molokai.git master diff --git a/.vim/bundletab b/.vim/bundletab deleted file mode 100644 index a2b9c21..0000000 --- a/.vim/bundletab +++ /dev/null @@ -1,14 +0,0 @@ -# $HOME/.vim/bundletab -# -# This file contains a table of vim plugins that are to be installed in the -# $HOME/.vim/bundle directory. Pathogen will load these as needed. -# -# Local name Remote URL Branch -# -feature-camelcasemotion https://github.com/tyil/camelcasemotion.git master -syntax-helm https://github.com/towolf/vim-helm master -syntax-perl6 https://github.com/vim-perl/vim-perl6.git master -syntax-terraform https://github.com/hashivim/vim-terraform master -theme-colorsbox https://github.com/mkarmona/colorsbox.git master -theme-jellybeans https://github.com/nanotech/jellybeans.vim.git master -theme-molokai https://github.com/tomasr/molokai.git master -- cgit v1.1