On Dir - Automatic script execution
About
On Dir is a program that automatically executes scripts as you traverse directories at a terminal.
Example usage
["alec@cavern:~"]umask 077 ["alec@cavern:~"]cd public_html ["alec@cavern:~/public_html"]umask 022 ["alec@cavern:~/public_html"]cd ["alec@cavern:~"]umask 077
The above is accomplished with the help of ondir, some scripts added to the users (or system) startup scripts and an entry in my ~/.ondirrc for the ~/public_html path.
The entry in my ~/.ondirrc would look like this
enter /home/athomas/public_html umask 022 leave /home/athomas/public_html umask 077
In addition to executing scripts in the directory you are entering or leaving, ondir also executes scripts in directories that are traversed on the way to that directory. For example, if you are in your home directory and type
cd ~/public_html/myproject
On Dir scripts for ~/public_html and ~/public_html/myproject are executed because these directories are traversed.
You can download On Dir from the bottom of this page.
News
Tips and Tricks
On Dir has acquired a couple of very nice features over the years, here are a couple.
Tilde expansion in paths.
enter ~/public_html umask 022 leave ~/public_html umask 077
Expansion of environment variables in the form $VAR or ${VAR}.
The environment variable $ONDIRWD is always set to the directory being traversed. This is not equivalent to $PWD, as $PWD is the destination directory, whereas $ONDIRWD is the directory that matched during path traversal.
enter $HOME/public_html:/opt/movies echo "You have traversed $ONDIRWD"
Multiple paths per section.
enter /opt/movies:/opt/music umask 007 leave /opt/movies:/opt/music umask 077
Regular expressions, including sub-pattern capturing and referencing (sub-patterns are assigned to the environment variables $0 through $9).
enter ~/projects/(ondir|todo) echo "Welcome to $1" leave ~/projects/(ondir|todo) echo "Thanks for visiting $1"
Download
- ondir-0.2.2.tar.gz
- ondir-0.2.1.tar.gz
- ondir-0.2.0.tar.gz
- ondir-0.1.5.tar.gz
- ondir-0.1.3.tar.gz
- ondir-0.1.2.tar.gz
- ondir-0.1.1.tar.gz
- ondir-0.1.0.tar.gz
Change Log
[446] by athomas on 08/13/2007 08:19:03 PM
On Dir: Added final clause.
[445] by athomas on 08/13/2007 07:56:32 PM
On Dir: All enter/leave blocks whose patterns match will execute, in order.
[431] by athomas on 05/22/2007 09:28:31 PM
On Dir: Only expand environment variables set explicitly by On Dir. Let the shell pick up the rest.
[334] by athomas on 04/30/2006 12:01:00 AM
Updated some mime-types.
[333] by athomas on 04/29/2006 11:55:50 PM
Initial import.
