(dired.info)dired-cd.el


Next: dired-nstd.el Prev: dired-trns.el Up: Tree Dired Extra

Changing the Working Directory for Dired Shell Commands
=======================================================

   The package `dired-cd.el' permits the working directory of the Dired
shell commands `!' (`dired-do-shell-command') and `&'
(`dired-do-background-shell-command') to be the files' subdirectory
under certain circumstances.  Loading this extension does not change the
behavior of Dired until the variables `dired-cd-same-subdir' and/or
`dired-cd-on-each' are non-nil.

   If `dired-cd-same-subdir' is non-nil and if all the selected files
(marked, non-zero numeric argument, etc.) are in the same subdirectory,
then `dired-do-shell-command' and `dired-do-background-shell-command'
cause the shell to perform a `cd' into that directory before the
commands are executed.  Also, the selected filenames are provided to
the command without any directory components.

   If `dired-cd-on-each' is non-nil and if the `on-each' option is
specified (numeric argument of zero), then `!'
(`dired-do-shell-command') and `&'
(`dired-mark-background-shell-command') use a subshell to perform a
`cd' into the subdirectory of each file before the commands on that
file are executed.  Also, each filename is provided to the command
without any directory components.  Note that this behavior occurs
regardless of whether the files are all in the same directory or not.

   After the above `cd' wrapping has occured, the existing
`dired-shell-stuff-it' is used to do the actual file-name quoting and
substitution into the command.  Thus, custom versions of this procedure
should work, e.g., the `dired-trans' package will transform commands
correctly.  However, since filenames lack any directory components,
features that use the directory components will fail, e.g.  the `[d]'
transform specifier will be empty.

   To use this package, load it in your `dired-load-hook'.  Do

     (setq dired-cd-same-subdir t)

and perhaps

     (setq dired-cd-on-each t)

in your `~/.emacs'.  By default, `dired-cd' doesn't change the behavior
of Dired when it is loaded.

   If `dired-cd-same-subdir' is non-nil, then the shell commands `cd'
to the appropriate directory if all the selected files are in that
directory; however, on-each behavior (with zero prefix argument) is not
changed.

   If `dired-cd-on-each' is non-nil, then each instance of the command
for an on-each shell command runs in the file's directory regardless of
whether the files are all in the same directory.


automatically generated by info2www