]> git.donarmstrong.com Git - zsh.git/blob - .zsh/func/vcsh
do not exit but return and make prompt standout
[zsh.git] / .zsh / func / vcsh
1 #!/bin/sh
2 #
3 # func/vcsh
4 #
5 # set the context for vcs-home operations
6 #
7 # Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
8 # Released under the terms of the Artistic Licence 2.0
9 #
10 # Source repository: http://git.madduck.net/v/etc/zsh.git
11 #
12
13 FGIT_BASE="$HOME/.fgits"
14
15 if [ "${1:---help}" = '--help' ] || [ $# -gt 1 ]; then
16   echo "usage: ${0%/*} reponame" >&2
17   echo "usage: ${0%/*} -l" >&2
18   [ "$1" = '--help' ]
19   return $?
20
21 elif [ "$1" = '-l' ]; then
22   for i in $FGIT_BASE/*.git; do
23     i="${i#$FGIT_BASE/}"
24     echo "${i%.git}"
25   done
26   return 0
27 fi
28
29 if [ ! -d "$FGIT_BASE/${1}.git" ]; then
30   echo E: no repository found for "$1" >&2
31   return 2
32 fi
33
34 export GIT_DIR=$FGIT_BASE/${1}.git
35 git status
36
37 PS1="%S{VCSH:$1}%s$PS1" $SHELL -i