bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bash feature request: pushd -v, popd -v


From: Dave Rutherford
Subject: Re: bash feature request: pushd -v, popd -v
Date: Sat, 16 Jul 2005 00:07:27 -0400

On 7/15/05, Ben Horowitz <bhorowitspam@gmail.com> wrote:
> 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       /

Does this do the trick?

pushd ()
{
    local verbose=0;
    if [ "$1" = "-v" ]; then
        verbose=1;
        shift;
    fi;
    builtin pushd "$@";
    if [ $verbose -eq 1 ]; then
        for w in ${!DIRSTACK[@]};
        do
            echo "$w    ${DIRSTACK[$w]}";
        done;
    fi
}

Barely tested (and with bash 3.0 at that), but it seems to do
what you want.  popd would be very similar, of course.

Dave




reply via email to

[Prev in Thread] Current Thread [Next in Thread]