Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
athomas
committed
Apr 30, 2006
0 parents
commit 4c4e395
Showing
16 changed files
with
1,370 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!-- Automagically generated by the ToDo program on 24/12/03, 01:02 --> | ||
<todo version="0.1.18"> | ||
<title> | ||
OnDir | ||
</title> | ||
<note priority="high" time="1010116249" done="1058069395"> | ||
Rewrite in C to make it more portable? | ||
</note> | ||
<note priority="medium" time="1007514655" done="1007558816"> | ||
Support for tcsh | ||
</note> | ||
<note priority="medium" time="1007833233" done="1007909284"> | ||
Obtain enter/leave list from a user-specific config file? (~/.ondir?) Would alleviate security problems. | ||
</note> | ||
<note priority="low" time="1007909398" done="1058069396"> | ||
There are two problems with the RC file. One is that if there are unmatched braces, the lexer will die. The other is if there are strings which contain newlines inside the scripts they will be changed to ;'s. | ||
</note> | ||
</todo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Alec Thomas <alec@swapoff.org> |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
0.2.2 | ||
* Added ~ expansion in ~/.ondirrc paths (only works if ~ is first character) | ||
* Added envar expansion in the definition and bodies of enter/leave sections. | ||
eg. | ||
enter $HOME/projects/.* | ||
echo "You have entered ${ONDIRWD}" | ||
* Added regular expression sub-pattern capturing. This lets you do things like: | ||
{{{ | ||
enter $HOME/cvs/([^/]+)/? | ||
echo "You have entered the CVS directory for $1" | ||
}}} | ||
$0 is equivalent to $ONDIRWD. Thanks to Wolfram Schlich for this idea. Nice. | ||
|
||
0.2.1 | ||
* Fixed stupid compile problem when .onenter/.onleave support is enabled. | ||
Thanks to Steve Huff for picking this up. | ||
* Added a patch from Arvind SV which adds regex matching support for paths. | ||
Nice. eg. enter /usr/src/linux(-2.4.21(-xfs)?)? | ||
* Arvind also added $ONDIRWD support from the pre-0.2.x versions back in. Quite | ||
a handy thing to have, thanks Arvind. | ||
|
||
0.2.0 | ||
* Rewritten in C. This makes it smaller and faster and no longer takes half an | ||
hour to compile. | ||
* Configuration file format has changed completely. Read the README or man page | ||
for more information. | ||
* No longer using autoconf/automake as it's overkill for 400 lines of source. | ||
|
||
0.1.6 | ||
* Fixed some errors in the man page, picked up thanks to Wolfram Schlich. | ||
* Fixed some potential quoting problems in the man page and migrate.sh. | ||
|
||
0.1.5 | ||
* Commented out some extraneous functions (drand) which were not being used but | ||
caused compile problems on OSX. | ||
* Fixed some other compilation issues on OSX. Thanks to Ben Hines for both of | ||
these OSX fixes. | ||
* Fixed some fairly major problems in the man page, referring to todorc rather | ||
than ondirrc. Thanks again to Ben Hines for picking this up. | ||
* Re-added .onenter/.onleave support, but optionally (use -o to enable this | ||
behaviour). | ||
* You can now pass the current working directory on the command line as the | ||
second option. This fixes problems with traversing paths containing symlinks. | ||
Thanks to Ralf Engelschall for pointing this out. | ||
* Cleaned up the code a bit. | ||
|
||
0.1.4 | ||
* Applied a patch sent in by Jason Kissinger to fix some cases where ; was not | ||
being added to the end of shell lines, causing TCSH to barf. | ||
* The rc file lexer no longer uses regular expressions, but hard-coded lexical | ||
element recognisers. It is an order of magnitude faster. | ||
* OnDir will no longer execute .onenter or .onleave scripts. This was a security | ||
disaster waiting to happen. There is a script included in the distribution | ||
called migrate.sh which will migrate any existing .onenter/.onleave scripts | ||
into your ~/.ondirrc. It is used by passing the paths you wish to migrate as | ||
arguments. | ||
|
||
0.1.3 | ||
* Fixed Makefile.am in ./src so all the source files are packaged - duh. | ||
* Changed static reference to ~athomas/.ondirrc to the generic case of | ||
$HOME/.ondirrc. Another stupid one. | ||
* Fixed broken TCSH handling. Thanks to Daniel Macks for hunting this down as | ||
well as the previous bug. | ||
|
||
0.1.2 | ||
* Now check for a .onexit as well. | ||
* Unset ONDIRWD variable after scripts have executed. | ||
* Added a config file /etc/ondirrc or ~/.ondirrc that contains directories and | ||
enter/exit scripts. This is the most secure way of having scripts execute and | ||
is preferred over .onenter and .onleave. See man page for further information. | ||
Thanks to Darren Chamberlain for this idea. | ||
|
||
0.1.1 | ||
* Added a patch sent in by Mira Temp�r to check for group/other write | ||
permissions on the scripts and refuse to run them if they are set. | ||
Subsequently changed the name of the function to make more sense. | ||
* Added -V to display version. | ||
|
||
0.1.0 | ||
* Released. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
The default is to install the binary and man page into /usr and to look for | ||
the global config in /etc. | ||
|
||
If you wish to install entirely into /usr/local, do the following: | ||
|
||
make PREFIX=/usr/local CONF=/usr/local/etc/ondirrc install | ||
|
||
To install to a "package root" do this: | ||
make DESTDIR=/tmp/ondir.pkg install | ||
|
||
Once you have installed OnDir, add either scripts.sh or scripts.tcsh to your | ||
startup. This will execute ondir whenever you change directories at the shell. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Change these as you see fit | ||
PREFIX=/usr | ||
CONF=/etc/ondirrc | ||
|
||
SOURCES=conf.c ondir.c | ||
HEADERS=conf.h ondir.h | ||
OBJS=conf.o ondir.o | ||
TARGET=ondir | ||
|
||
VERSION=0.2.3 | ||
DESTDIR= | ||
|
||
# Add -DUSE_ONENTERLEAVE to CFLAGS to enable support for .onenter/.onleave | ||
# scripts. | ||
# **WARNING** This is not recommended at all. | ||
|
||
CC=cc | ||
CFLAGS=-O3 -DVERSION=\"$(VERSION)\" -DGLOBAL_CONF=\"$(CONF)\" -DUSE_ONENTERLEAVE | ||
CFLAGS=-Wall -c -g -DVERSION=\"$(VERSION)\" -DGLOBAL_CONF=\"$(CONF)\" | ||
|
||
LD=cc | ||
LDFLAGS= | ||
LDFLAGS=-g | ||
|
||
$(TARGET): $(OBJS) | ||
$(LD) $(OBJS) $(LDFLAGS) -o $@ | ||
@echo | ||
@echo "OnDir is built." | ||
@echo | ||
@echo "Type 'make DESTDIR=<pkg-root> install' to install." | ||
@echo | ||
|
||
clean: | ||
rm -f $(OBJS) $(TARGET) | ||
|
||
install: $(TARGET) | ||
install -m 755 -d $(DESTDIR)$(PREFIX)/man/man1 | ||
install -m 644 ondir.1 $(DESTDIR)$(PREFIX)/man/man1 | ||
install -m 755 -d $(DESTDIR)$(PREFIX)/bin | ||
install -m 755 ondir $(DESTDIR)$(PREFIX)/bin | ||
|
||
package: slackware rpm | ||
chown athomas:athomas * | ||
chmod og-rwx * | ||
chmod a+r ondir-$(VERSION)* | ||
|
||
slackware: $(TARGET) | ||
# Make SlackWare package | ||
rm -rf /tmp/ondir.pkg && \ | ||
make DESTDIR=/tmp/ondir.pkg PREFIX=/usr CONF=/etc/ondirrc install && \ | ||
cd /tmp/ondir.pkg && \ | ||
makepkg -l y -c y ${PWD}/ondir-$(VERSION)-i386-1.tgz && \ | ||
rm -rf /tmp/ondir.pkg | ||
|
||
rpm: dist $(TARGET) | ||
cp ondir-$(VERSION).tar.gz /usr/src/rpm/SOURCES | ||
rpm -ba ondir.spec | ||
cp /usr/src/rpm/SRPMS/ondir-$(VERSION)-1.src.rpm ${PWD} | ||
cp /usr/src/rpm/RPMS/i386/ondir-$(VERSION)-1.i386.rpm ${PWD} | ||
|
||
dist: clean | ||
rm -f ondir-$(VERSION)* && \ | ||
todo -T && \ | ||
cd .. && \ | ||
mv ondir ondir-$(VERSION) && \ | ||
tar -czv --exclude 'old/*' --exclude '.*.swp' -f ondir-$(VERSION).tar.gz ondir-$(VERSION) && \ | ||
mv ondir-$(VERSION) ondir && \ | ||
mv ondir-$(VERSION).tar.gz ondir | ||
|
||
dep: | ||
@makedepend $(CXXFLAGS) $(SOURCES) 2> /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
Introduction | ||
------------ | ||
ondir is a small program to automate tasks specific to certain directories. It | ||
works by executing scripts in directories when you enter and leave them. | ||
|
||
Scripts in the doc subdirectory show how to automate this when using either | ||
BASH or TCSH. | ||
|
||
Getting Started | ||
--------------- | ||
1. Add scripts.sh or scripts.tcsh to your startup scripts for BASH or TCSH, | ||
respectively. | ||
2. Restart your shell. | ||
3. Add an entry to your ~/.ondirrc such as those described below. | ||
4. Change into the corresponding path. | ||
5. Check for success. | ||
|
||
Details | ||
------- | ||
An example of ondirs usefulness is when editing web pages. I have a umask of 077 | ||
by default, but when creating web pages in ~/public_html the web content has | ||
to be readable by the user the web server runs as. By adding a path section for | ||
this directory to my ~/.ondirrc, and corresponding enter and leave sub-sections, | ||
any scripts in the enter/leave sub-sections are executed when I enter and leave | ||
the directory, respectively. Here is how the entry in my ~/.ondirrc would look: | ||
|
||
enter /home/athomas/public_html | ||
umask 022 | ||
|
||
leave /home/athomas/public_html | ||
umask 077 | ||
|
||
And that's all it does. Simple, but effective. | ||
|
||
ondir takes one parameter, the directory you are leaving. | ||
|
||
Note that these scripts will be executed when you pass THROUGH the directory | ||
as well. Using the preceding example, typing "cd ~/public_html/mywebpage" will | ||
execute the 'enter' in ~/public_html. The reverse is also true: when leaving | ||
a path, all 'leave' scripts in the intermediate directories are executed. | ||
|
||
Another useful example is if you have a project with its own "bin" directory. | ||
You can use the following: | ||
|
||
enter /home/athomas/projects/myproject | ||
PATH=$PATH:$ONDIRWD/bin | ||
|
||
leave /home/athomas/projects/myproject | ||
PATH=`echo $PATH | sed -e "s,:$ONDIRWD/bin,,g"` | ||
|
||
Example of usage: | ||
|
||
[alec@cavern:~]umask | ||
077 | ||
[alec@cavern:~]cd public_html | ||
[alec@cavern:~/public_html]umask | ||
022 | ||
[alec@cavern:~/public_html] |
Empty file.
Oops, something went wrong.