[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bash feature request: pushd -v, popd -v
From: |
Chet Ramey |
Subject: |
Re: bash feature request: pushd -v, popd -v |
Date: |
Fri, 15 Jul 2005 23:52:38 -0400 |
User-agent: |
Mozilla Thunderbird 1.0.2 (Macintosh/20050317) |
Ben Horowitz wrote:
> Hi,
>
> I love bash, and I've been using it for a number of years. Recently,
> I worked with software engineers who used tcsh primarily, where I grew
> to appreciate one feature of tcsh: the ability to use the commands
> pushd -v, and popd -v.
>
> As you know, when the bash pushd and popd commands are successful,
> they print the directory stack. In tcsh, one can additionally issue
> the command pushd -v, which is like the bash commands pushd followed
> by dirs -v. This feature appears not to be available in bash.
>
> tcsh> pushd -v /tmp
> 0 /tmp
> 1 /
>
> I find this to be a good feature of tcsh because I find that the
> output of dirs without the -v argument can get cluttered, especially
> when there are many directories on the stack.
Here's a first cut. Salt to taste (yes, you should use getopts):
pushd()
{
local es
case "$1" in
-v) vflag=y; shift ;;
esac
builtin pushd "$@"
es=$?
[ -n "$vflag" ] && dirs -v
return $es
}
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet )
Live...Laugh...Love
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/