5 # set the context for vcs-home operations
7 # Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
8 # Released under the terms of the Artistic Licence 2.0
10 # Source repository: http://git.madduck.net/v/etc/zsh.git
13 local FGIT_BASE="$HOME/.fgits"
15 if [ "${1:---help}" = '--help' ] || [ $# -gt 1 ]; then
16 echo "usage: ${0##*/} reponame" >&2
17 echo "usage: ${0##*/} -l" >&2
21 elif [ "$1" = '-l' ]; then
22 for i in $FGIT_BASE/*.git; do
29 if [ ! -d "$FGIT_BASE/${1}.git" ]; then
30 echo E: no repository found for "$1" >&2
34 old_GIT_DIR="${GIT_DIR:-}"
35 old_GIT_WORK_TREE="${GIT_WORK_TREE:-}"
37 export GIT_DIR="$FGIT_BASE/${1}.git"
38 export GIT_WORK_TREE="$GIT_DIR/$(git config --get core.worktree)"
42 PS1="%S{${0##*/}:$1}%s$PS1" $SHELL -i || :
44 GIT_DIR="$old_GIT_DIR"
45 [ -z "$GIT_DIR" ] && unset GIT_DIR
46 GIT_WORK_TREE="$old_GIT_WORK_TREE"
47 [ -z "$GIT_WORK_TREE" ] && unset GIT_WORK_TREE