Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

People also ask

What is pushd and popd in bash?

In computing, pushd and popd are commands used to work with the command line directory stack. They are available on command-line interpreters such as 4DOS, Bash, C shell, tcsh, Hamilton C shell, KornShell, cmd.exe, and PowerShell for operating systems such as DOS, Microsoft Windows, ReactOS, and Unix-like systems.

How do you use pushd and popd?

The popd CommandTo change the directory, do something, and then hop back to the previous directory, you can use pushd and popd together. We'll use pushd to move to a different directory. We'll use popd to discard the topmost directory in the stack and move to the directory in the second position.

What does pushd do in CMD?

The pushd command stores a directory or network path in memory so that it may be accessed at any time.

What is the pushd command in bash?

To store the current directory information in the stack before moving to another directory location, `pushd` command is used in bash. This command works on LIFO (Last In First Out) based. This means, the directory information will be stored at the end of the stack location.


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.


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

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