Don't display pushd/popd stack across several bash scripts (quiet pushd/popd)

坚强是说给别人听的谎言 提交于 2019-11-29 01:19:48

问题


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.


回答1:


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.




回答2:


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



回答3:


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



来源:https://stackoverflow.com/questions/25288194/dont-display-pushd-popd-stack-across-several-bash-scripts-quiet-pushd-popd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!