diff --git a/Makefile b/Makefile old mode 100644 new mode 100755 index b40c618f..5ac89eda --- a/Makefile +++ b/Makefile @@ -5,7 +5,8 @@ ZSHDIR=$(PREFIX)/share/zsh/vendor-completions RONN ?= ronn self=vcsh -manpages=$(self).1 +vcsha=vcsha +manpages=$(self).1 $(vcsha).1 all=test all: $(all) @@ -13,6 +14,7 @@ all: $(all) install: all install -d $(DESTDIR)$(PREFIX)/bin install -m 0755 $(self) $(DESTDIR)$(PREFIX)/bin + install -m 0755 $(vcsha) $(DESTDIR)$(PREFIX)/bin install -d $(DESTDIR)$(PREFIX)/share/man/man1 install -m 0644 $(manpages) $(DESTDIR)$(PREFIX)/share/man/man1 install -d $(DESTDIR)$(DOCDIR) @@ -26,12 +28,17 @@ manpages: $(manpages) $(self).1: doc/$(self).1.ronn $(RONN) < doc/$(self).1.ronn > $(self).1 || rm $(self).1 +$(vcsha).1: doc/$(vcsha).1.ronn + $(RONN) < doc/$(vcsha).1.ronn > $(vcsha).1 || rm $(vcsha).1 + clean: - rm -rf $(self).1 + rm -rf $(self).1 $(vcsha).1 uninstall: rm -rf $(DESTDIR)$(PREFIX)/bin/$(self) + rm -rf $(DESTDIR)$(PREFIX)/bin/$(vcsha) rm -rf $(DESTDIR)$(PREFIX)/share/man/man1/$(self).1 + rm -rf $(DESTDIR)$(PREFIX)/share/man/man1/$(vcsha).1 rm -rf $(DESTDIR)$(DOCDIR) rm -rf $(DESTDIR)$(ZSHDIR)/_$(self) diff --git a/README-vcsha.md b/README-vcsha.md new file mode 100755 index 00000000..f12b68d2 --- /dev/null +++ b/README-vcsha.md @@ -0,0 +1,36 @@ +Introduction +============ + +An add-on to allow VCSH (https://github.com/RichiH/vcsh) to manage +arbitrary directories. + +VCSH is a tool that allows you to manage files in your $HOME in +multiple different git repositories. + +This script is an addition that allow you to apply the same kind of +management to files in arbitrary directories *NOT* under $HOME. + + +Use +=== + +VCSHA attempts to be anaogous to the way git locates its repositories. + +Use `vcsha init` in a directory to mark it for management by vcsha. + +After that, use vcsha just as you would use vcsh but you will be +managing files underneath the marked directoriy. + +Details +======= + +As it stands, VCSH really wants to only manage files under $HOME. +However, it has a mechanism (enviornment variable "VCSH_BASE" (see +https://github.com/RichiH/vcsh/issues/112)) to work on other +directories. + +This script uses a marker directory ".vcsha" in the file system to +locate a vcsh managed directory, sets VCSH_BASE and XDG_CONFIG_HOME +appropriately, then delegates all interesting work to vcsh. + +This is useless without VCSH and is a fairly trivial addition to VCSH. diff --git a/doc/vcsha.1.ronn b/doc/vcsha.1.ronn new file mode 100755 index 00000000..5b4e76c7 --- /dev/null +++ b/doc/vcsha.1.ronn @@ -0,0 +1,59 @@ +vcsha(1) - Use vcsh(1) on arbitrary directories +=============================================== + +## SYSTEM +`vcsha` init + +`vcsha` + +## DESCRIPTION + +This script is an addition that allow you to apply vcsh to files in +arbitrary directories *NOT* under $HOME. + +## OPTIONS + +none + +## COMMANDS + +* init: + initialize the current directory for vcsh operations. NOTE: if + `init` is passed any arguments, the whole command line will be + passed through to vcsh and have different results. + +* any vcsh command + See `vcsh`(1) for commands and options. + +## ENVIRONMENT + +Sets $VCSH_BASE and $XDG_CONFIG_HOME to the directory found for vcsha +operations. + +## CONFIG + +Similar to git, `vcsha` will examine the directory tree from the +current directory to the root directory for a ".vcsha" marker +subdirectory. If found, the directory containing ".vcsha" will be +taken to be the base of all `vcsh`(1) operations and the environment +variables will be set to that the directory containing .vcsha. `vcsha +init` is a convenience method for creating this directory. + +## AUTHOR + +This manpage and `vcsha` were written by Dewey Sasser. The script is +a trivial wrapper around the excellent work by Richard "RichiH" +Hartmann. + +## COPYRIGHT + +Copyright 2014 Dewey Sasser + +Licensed under the GNU GPL version 2 or higher. + +https://github.com/RichiH/vcsh + +## SEE ALSO + +`vcsh`(1) + diff --git a/vcsha b/vcsha new file mode 100755 index 00000000..4b805395 --- /dev/null +++ b/vcsha @@ -0,0 +1,30 @@ +#!/bin/sh + +# Purpose: wrap vcsh to allow management of arbitrary directories + +finddir() { + ( + while [ `pwd` != / ] ; do + if [ -d .vcsha ] ; then + pwd + fi + cd .. + done + ) +} + +if [ "$1" = "init" -a "$#" -eq 1 ] ; then + mkdir .vcsha + exit 0 +fi + +dir=`finddir` + +if [ -z "$dir" ] ; then + echo "Not in a vcsha repository. Use vcsha init to create a repository" + exit 1 +fi + +export VCSH_BASE="$dir" +export XDG_CONFIG_HOME="$dir" +exec vcsh "$@"