Last active
December 13, 2018 16:37
-
-
Save robmiller/5849541 to your computer and use it in GitHub Desktop.
Quickly add Tim Pope's ctags generation scripts to all Git-controlled directories under the current one, so that you don't need to recreate your repositories.
This file contains hidden or 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
# I love tpope's solution to ctags regeneration[1]; he creates | |
# a template from which all Git repositories take their default hooks, | |
# and then uses these hooks to regenerate ctags. | |
# | |
# [1]: http://tbaggery.com/2011/08/08/effortless-ctags-with-git.html | |
# | |
# It's an elegant solution, but what do you do about repositories that | |
# already exist? The template will only apply to newly cloned or newly | |
# initialised repositories. | |
# | |
# This one-liner should help; it will check for version-controlled | |
# directories one level below the current directory, and then copy the | |
# hooks over into them. | |
for x in *; do; [[ -d "$x/.git" ]] && echo $x && git init; done | |
# This won't actually generate the ctags; they'll be generated the next | |
# time one of the hooks is run (e.g. the next time you do a pull). | |
# | |
# If you'd like to regenerate them without waiting, you can use the | |
# following: | |
for x in *; do; [[ -e "$x/.git/hooks/ctags" ]] && echo $x && chdir $x && .git/hooks/ctags && cd ..; done |
You can also run git init
on an existing git repository, which applies your global git templates anew. From the git init documentation
Running
git init
in an existing repository is safe. It will not overwrite things that are already there. The primary reason for rerunninggit init
is to pick up newly added templates.
Amazing! Much simpler.
Updated.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could also do this with a
find
command, I suppose (untested):