aboutsummaryrefslogtreecommitdiff
path: root/mrconfig-updater
blob: 1403276216aacbde1cccefb40ee6b7ea8255d6d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
#
# Generates a `~/.custom/mrconfig-automatic` file with
# autodetected repositories from some folders.
#
# To use this file, just add the following on your ~/.mrtrust:
#
#   custom/mrconfig-automatic
#
# and the following on your ~/.mrconfig:
#
#   include = cat ~/.custom/mrconfig-automatic
#

# Configuration
MRCONFIG="$HOME/.custom/mrconfig-automatic"
FOLDERS="apps file code .dotfiles"
DEPTH="2"
CWD="`pwd`"

# Setup
cd $HOME
rm -f $MRCONFIG

# Iterate
for folder in $FOLDERS; do
  if [ ! -d "$folder" ]; then
    continue
  fi

  # A trailing slash helps to find following symbolic links
  find $folder/ -maxdepth $DEPTH -name '.git' | while read repo; do
    echo "[`dirname $repo`]" >> $MRCONFIG
  done
done

# Teardown
cd $CWD