|The last directory you were in, after having changed to the new directory.|
|The current directory. This is optional, but can be useful when traversing symbolically linked paths, as it will use the logical path rather than the physical path. If left out, ondir uses getcwd().|
The configuration files /etc/ondirrc and ~/.ondirrc are in the form:
[final] enter <path>[:<path>[:...]]
<shell script body>
[final] leave <path>[:<path>[:...]]
<shell script body>
Any line with leading whitespace is assumed to belong to the last valid enter or leave section.
final indicates that the section will be the last one executed for the matching directory. Directories further down the hierarchy will still be matched.
<path> is the path to match. Regular expression support has been included since version 0.2.1 thanks to Arvind (?). A path must match completely to be considered a match. Because : is the path delimiter, it can not be used in any regular expressions.
Arvind also re-added (from version 0.1.x) support for $ONDIRWD expansion. This environment variable will contain the directory currently being traversed.
A perfect example of the usefulness of this program is a users public_html directory.
I personally set my default umask to 077, but when editing in my public_html directory I want my umask to be 022. To do this automatically, I would have add the following to my ~/.ondirrc
~/.ondirrc enter /home/athomas/public_html
Another good example is if you have a "bin" directory in a project, but dont want to add it permanently to your PATH. The following ondir scripts take care of that: ~/.ondirrc enter /home/athomas/projects/myproject
PATH=echo $PATH | sed -e "s,:$CWD/bin,,g"
The BASH script you should add to your profile is:
builtin cd "$@" && eval "ondir \"$OLDPWD\" \"$PWD\""
builtin pushd "$@" && eval "ondir \"$OLDPWD\" \"$PWD\""
builtin popd "$@" && eval "ondir \"$OLDPWD\" \"$PWD\""
eval "ondir /"
The TCSH script you should add to your profile is:
alias cwdcmd eval #145;ondir \$owd \$cwd#145;
# Run ondir on login
eval ondir /
Alec Thomas <firstname.lastname@example.org>
ondir also has the ability to execute scripts in the directories being traversed. These scripts are named .onenter and .onleave. This ability is disabled by default, but can be enabled by editing conf.h and uncommenting:
|Alec Thomas||ONDIR (1)||0.2.3|