28

After calling pushd/popd in bash, it will print off the current directory stack. Is there any way to prevent this behaviour, so that it will act 'quitely'? This sort of noise in a command is uncommon in unix tools.

2 Answers 2

41

I think this sort of "noise" is not uncommon, that's why you often do this:

pushd > /dev/null
6
  • 1
    You can also make a function to basically redefine the command and stick it in .bashrc such as: pushd() { builtin pushd $1 > /dev/null; }
    – violet
    Feb 1, 2010 at 2:02
  • 5
    @jrod: Since pushd can takes multiple arguments, you might want that as pushd() { builtin pushd "$@" > /dev/null; } and the quotes handle directory names with spaces. Feb 1, 2010 at 2:52
  • 3
    I'd say its uncommon. The linux philosophy is actually to not print anything if everything went well except the output of the program or builtin if any. For example cd, ls, aso.
    – vidstige
    Jan 15, 2015 at 17:54
  • 1
    Some people do pushd &> /dev/null. I'd say don't do that because & means redirect both stdout and stderr. Normally you only want to redirect stdout. Jul 21, 2017 at 0:35
  • 1
    popd also generates console output, so consider silencing it in the same way Mar 11, 2018 at 18:01
-1

For the tcsh shell you can: set pushdsilent

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .