ondir man page on DragonFly

Man page or keyword search:  
man Server   44335 pages
apropos Keyword Search (all sections)
Output format
DragonFly logo
[printable version]

ondir(1)			 Shell utility			      ondir(1)

NAME
       ondir  -	 automatically	execute scripts when traversing directories at
       the command line

SYNPOSIS
       ondir <old-directory> [<new-directory>]

DESCRIPTION
       NOTE: The 0.2.x series has been completely rewritten in C. In addition,
       the configuration file format is substantially different.

       ondir  is  a  program that executes a script when entering or leaving a
       directory. It also executes all scripts in the intermediate directories
       between the two.

       For  example, when changing from /opt/music to /home, leave scripts for
       /opt/music and /opt are executed, then the enter script	for  /home  is
       executed.

       The   scripts   are   defined   in   either  the	 system-wide  rc  file
       (/etc/ondirrc) or per user rc files (~/.ondirrc).

       The way ondir works is by using auxiliary scripts that  override	 shell
       builtins	 (cd, pushd and popd in BASH) to execute ondir whenever a user
       changes directory. These scripts are included in the  section  SCRIPTS,
       below.

       The  scripts  are  available  in	 the  source  tarball  and  are called
       scripts.sh, scripts.tcsh for Bourne shell variants  and	TCSH,  respec‐
       tively.

OPTIONS
       <old-directory>
	      The  last directory you were in, after having changed to the new
	      directory.

       [<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().

CONFIGURATION
       The configuration files /etc/ondirrc and ~/.ondirrc are in the form:

       # Comment
       [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 expan‐
       sion. This environment variable will contain  the  directory  currently
       being traversed.

       A  perfect  example  of	the usefulness of this program is a users pub‐
       lic_html directory.

       I personally set my default umask to 077, but when editing in  my  pub‐
       lic_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
		   umask 022
	      leave /home/athomas/public_html
		   umask 077

       Another good example is if you have a "bin" directory in a project, but
       don't  want  to	add  it	 permanently to your PATH. The following ondir
       scripts take care of that:

       ~/.ondirrc
	      enter /home/athomas/projects/myproject
		   PATH=$PATH:$CWD/bin
	      leave /home/athomas/projects/myproject
		   PATH=`echo $PATH | sed -e "s,:$CWD/bin,,g"`

SCRIPTS
       The BASH script you should add to your profile is:

       cd()
       {
	   builtin cd "$@" && eval "`ondir \"$OLDPWD\" \"$PWD\"`"
       }
       pushd()
       {
	   builtin pushd "$@" && eval "`ondir \"$OLDPWD\" \"$PWD\"`"
       }
       popd()
       {
	   builtin popd "$@" && eval "`ondir \"$OLDPWD\" \"$PWD\"`"
       }
       eval "`ondir /`"

       The TCSH script you should add to your profile is:

       alias cwdcmd eval \`ondir \$owd \$cwd\`
       # Run ondir on login
       eval `ondir /`

AUTHORS
       Alec Thomas <alec@swapoff.org>

SEE ALSO
       devtodo(1) <http://swapoff.org/DevTodo>

NOTES
       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 uncom‐
       menting:

       #define USE_ONENTERLEAVE

Alec Thomas			     0.2.3			      ondir(1)
[top]

List of man pages available for DragonFly

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net