]> git.madduck.net Git - etc/zsh.git/blob - .zsh/func/vcsh

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

use … in prompt expansion truncation
[etc/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: git://git.madduck.net/etc/zsh.git
11 #
12
13 local 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 old_GIT_DIR="${GIT_DIR:-}"
35 old_GIT_WORK_TREE="${GIT_WORK_TREE:-}"
36
37 export GIT_DIR="$FGIT_BASE/${1}.git"
38 export GIT_WORK_TREE="$GIT_DIR/$(git config --get core.worktree)"
39
40 PS1="%S{${0##*/}:$1}%s$PS1" $SHELL -i || :
41
42 GIT_DIR="$old_GIT_DIR"
43 [ -z "$GIT_DIR" ] && unset GIT_DIR
44 GIT_WORK_TREE="$old_GIT_WORK_TREE"
45 [ -z "$GIT_WORK_TREE" ] && unset GIT_WORK_TREE