Don't display pushd/popd stack across several

2020-02-23 04:33发布

Each time I use pushd or popd, it print the stack to standard output. How not to do so?

I don't want to do pushd > /dev/null each time because I have a lot of scripts calling each other.

Maybe a nice override will do it, but I'll need to override these builtins only in my scripts, and then restore the correct behavior.

3条回答
我命由我不由天
2楼-- · 2020-02-23 05:09

You could add

pushd () {
    command pushd "$@" > /dev/null
}

popd () {
    command popd "$@" > /dev/null
}

to the top of each script. This is probably the minimum amount of work it will take to solve your problem.

查看更多
够拽才男人
3楼-- · 2020-02-23 05:16

In your .profile file (what ever it is called in your system) add:

pushd () {
    command pushd "$@" > /dev/null
}

popd () {
    command popd "$@" > /dev/null
}

export pushd popd
查看更多
太酷不给撩
4楼-- · 2020-02-23 05:20

In zsh you can setopt PUSHDSILENT. Put this in your ~/.zshrc.

查看更多
登录 后发表回答