Feat: Add script for moving projects
[cookiecutter.git] / move-project
1 #! /bin/sh
2
3 if [ -z "$1" -o -n "$2" ]; then
4    echo "Usage: $0 project_name" >&2
5    exit 1
6 fi
7
8 project_name="$1"
9 old_dir="$HOME/admin/prog/$1"
10 new_dir="$HOME/prog/Python/$1"
11
12 fix_path() {
13    config_option="$1"
14    path="`git config --get $config_option`"
15    new_path="`echo \"$path\" | sed \"s@$old_dir@$new_dir@\"`"
16    git config "$config_option" "$new_path"
17 }
18
19 mv "$old_dir" "$new_dir" &&
20
21 for project_dir in "$new_dir" "$HOME"/current/projects/"$project_name" \
22       "$HOME"/Internet/WWW/htdocs/git.phdru.name/"$project_name".git; do
23    cd "$project_dir" &&
24    for remote in `git remote`; do
25       fix_path "remote.$remote.url"
26    done
27 done