Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Makefile
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ ZSHDIR=$(PREFIX)/share/zsh/vendor-completions
RONN ?= ronn

self=vcsh
manpages=$(self).1
vcsha=vcsha
manpages=$(self).1 $(vcsha).1
all=test

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)
Expand All @@ -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)

Expand Down
36 changes: 36 additions & 0 deletions README-vcsha.md
Original file line number Diff line number Diff line change
@@ -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.
59 changes: 59 additions & 0 deletions doc/vcsha.1.ronn
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
vcsha(1) - Use vcsh(1) on arbitrary directories
===============================================

## SYSTEM
`vcsha` init

`vcsha` <any vcsh arguments>

## 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 <dewey@sasser.com>

Licensed under the GNU GPL version 2 or higher.

https://github.com/RichiH/vcsh

## SEE ALSO

`vcsh`(1)

30 changes: 30 additions & 0 deletions vcsha
Original file line number Diff line number Diff line change
@@ -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 "$@"