27

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.

peterh
  • 4,953
  • 13
  • 30
  • 44
Amandasaurus
  • 31,471
  • 65
  • 192
  • 253

2 Answers2

40

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

pushd > /dev/null
Dennis Williamson
  • 62,149
  • 16
  • 116
  • 151
  • 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 01 '10 at 02: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. – Dennis Williamson Feb 01 '10 at 02:52
  • Good tip, but most unix tools don't print to the terminal EVERY TIME, but only if there's an error – Amandasaurus Feb 01 '10 at 10:05
  • 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 '15 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. – Shital Shah Jul 21 '17 at 00:35
  • 1
    `popd` also generates console output, so consider silencing it in the same way – Clare Macrae Mar 11 '18 at 18:01
-1

For the tcsh shell you can: set pushdsilent

kmcaron
  • 11