Small CLI util for including maintenance scripts in .<user> directory in git repos, where <user> is configured with following env variable
# Configure this with preferred directory in git repositories
export DOT_USER_GIT_UTIL_TARGET_FOLDER=".$USER"
# Source directory from which to copy scripts
export DOT_USER_GIT_UTIL_TEMPLATE_DIRECTORY=/path/to/template/directoryYou can find the summary of configuration options in the source code - here
Motivation for this util is to have a convenient interface for project maintenance through small layer of bash scripts, reused across multiple projects
Assuming all projects are stored in ~/Repositories
you should be able to find all repositories with following command
find ~/Repositories -type d -name .git -printf '%h\n'and then easily iterate them with
for repository in $(find ~/Repositories -type d -name .git -printf '%h\n'); do "$repository/.$USER/my-custom-script.sh"; doneor alias this command
alias take-care-of-stuff='for repository in $(find ~/Repositories -type d -name .git -printf "%h\n"); do echo "$repository/.$USER/my-custom-script.sh"; done'
take-care-of-stuffNote: recommended
Reusable user-specific things can be included in a custom template directory, however I decided to go with another directory for flexibility of whether to include the scripts in VCS
There is also a quick prompt, if you want to .gitignore the added scripts
Also, configuring DOT_USER_GIT_UTIL_TARGET_FOLDER=.git hasn't been tested (for obvious reasons) and it might/will lead to undesirable side-effects
-
Clone this repo
-
Run
make buildmake -C "dot-user-git-util" build -
set env variables
export DOT_USER_GIT_UTIL_TARGET_FOLDER=".$USER" export DOT_USER_GIT_UTIL_TEMPLATE_DIRECTORY="$PWD/dot-user-git-util/example-template"
-
Initialize cloned repo with template, that should be present in
"dot-user-git-util/$USER"./dot-user-git-util/bin/dot-user-git-util ./dot-user-git-util # Note that command takes multiple args # Alternatively you could do sth like # `find ~/Repositories` -type d -name .git -printf '%h\n' | xargs ./dot-user-git-util/bin/dot-user-git-util
-
Follow the quick prompt
-
Validate with
findfor repository in $(find . -type d -name .git -printf '%h\n'); do "$repository/$DOT_USER_GIT_UTIL_TARGET_FOLDER/hello"; done
- unit tests

