Skip to main content
Tweeted twitter.com/#!/StackUnix/status/556452126290100225
deleted 1 character in body
Source Link
Anthon
  • 81.4k
  • 42
  • 174
  • 228

This answer gave me cd - as shorthand to change to my previous directory in Bash. It does have a major problem: it prints the directory it changes to, wasting my screen space, as that directory is then repeated in the prompt on the next line.

I know I can do cd $OLDPWD, also mentioned in that answer, and cd - >/dev/null but that is much more typing.

In the bash man page it says:

... or if - is the first argument, and the directory change is successful, the absolute path name of the new working directory is written to the standard output.

How can I make - not to be the first argument? By using any of the cd optional arguementsarguments? Any other way to suppress the echo or minimise typing without the need for defining functions/aliases on every machine I work with?

This answer gave me cd - as shorthand to change to my previous directory in Bash. It does have a major problem: it prints the directory it changes to, wasting my screen space, as that directory is then repeated in the prompt on the next line.

I know I can do cd $OLDPWD, also mentioned in that answer, and cd - >/dev/null but that is much more typing.

In the bash man page it says:

... or if - is the first argument, and the directory change is successful, the absolute path name of the new working directory is written to the standard output.

How can I make - not to be the first argument? By using any of the cd optional arguements? Any other way to suppress the echo or minimise typing without the need for defining functions/aliases on every machine I work with?

This answer gave me cd - as shorthand to change to my previous directory in Bash. It does have a major problem: it prints the directory it changes to, wasting my screen space, as that directory is then repeated in the prompt on the next line.

I know I can do cd $OLDPWD, also mentioned in that answer, and cd - >/dev/null but that is much more typing.

In the bash man page it says:

... or if - is the first argument, and the directory change is successful, the absolute path name of the new working directory is written to the standard output.

How can I make - not to be the first argument? By using any of the cd optional arguments? Any other way to suppress the echo or minimise typing without the need for defining functions/aliases on every machine I work with?

Source Link
Ishran
  • 153
  • 1
  • 6

cd to previous directory without echo of directory name

This answer gave me cd - as shorthand to change to my previous directory in Bash. It does have a major problem: it prints the directory it changes to, wasting my screen space, as that directory is then repeated in the prompt on the next line.

I know I can do cd $OLDPWD, also mentioned in that answer, and cd - >/dev/null but that is much more typing.

In the bash man page it says:

... or if - is the first argument, and the directory change is successful, the absolute path name of the new working directory is written to the standard output.

How can I make - not to be the first argument? By using any of the cd optional arguements? Any other way to suppress the echo or minimise typing without the need for defining functions/aliases on every machine I work with?