add unicode-aware expand command
[hband-tools.git] / half-baked / gen-project-links
blobf26aef33c5397dd9d1501b3c503582e96383cc91
1 #!/bin/bash
3 # this script makes symlinks to git project directories which are in ~/src,
4 # and place these symlinks in directories names after the git project's author,
5 # which is generally the github owner's username.
7 mydir=`dirname "$0"`
8 cd "$mydir" || exit -1
10 for repo in ~/src/*/
12 author=''
13 if [ -d "$repo/.git" ]
14 then
15 for remote in github github.com origin
17 remote_url=`GIT_DIR=$repo/.git git remote get-url "$remote" 2>/dev/null`
18 if [ -n "$remote_url" ]
19 then
20 if [[ $remote_url =~ [/:]([^/]+)/([^/]+)/?$ ]]
21 then
22 author=${BASH_REMATCH[1]}
23 break
26 done
27 if [ -n "$author" ]
28 then
29 [ -d "$author" ] || mkdir "$author"
30 ln -snfr "$repo" "$author/"
31 else
32 echo "unknown author of $repo" >&2
35 done