CD hack with location history

Ήμουν σε ένα σύστημα που δεν είχε αυτό το , and reminded me how useful it is. So I thought I would share it with others.

Some of you may know about pushd and popd commands. The pushd is like the cd, but it watches and remembers where you were. You can then display as many levels as you want. It's like a cd but it keeps a history not only for the last time you used it.

The large my thing with pushd and popd is that in order for popd to work, i have to remember to do pushd first.

But, like most, from before, I issue commands in the terminal using the cd command. Until I realize that popd could be useful.

Now the hack.

Just pass him below in ~/.bashrc:
[pastacode =”function%20cd%0D%0A%7B%0D%0A%20%20%20%20if%20%5B%20%24%23%20-eq%200%20%5D%3B%20then%0D%0A%20%20%20%20%20%20%20%20pushd%20~%20%3E%20%2Fdev%2Fnull%0D%0A%20%20%20%20elif%20%5B%20%22%20%241%22%20%3D%20%22%20-%22%20%5D%3B%20then%0D%0A%20%20%20%20%20%20%20%20pushd%20%22%24OLDPWD%22%20%3E%20%2Fdev%2Fnull%0D%0A%20%20%20%20else%0D%0A%20%20%20%20%20%20%20%20pushd%20%22%24%40%22%20%3E%20%2Fdev%2Fnull%0D%0A%20%20%20%20fi%0D%0A%7D” provider=”manual” lang=”php”/] Και ξεκινήστε ένα νέο shell. Από εκείνο το σημείο και μετά, το cd θα τρέχει το pushd και το popd θα είναι πάντα διαθέσιμο όταν το χρειάζεστε.

Do you have a tip or a trick you want to share? If so, write a comment and we will give it as a post for everyone.

iGuRu.gr The Best Technology Site in Greeceggns

Get the best viral stories straight into your inbox!















Written by giorgos

George still wonders what he's doing here ...

Leave a reply

Your email address is not published. Required fields are mentioned with *

Your message will not be published if:
1. Contains insulting, defamatory, racist, offensive or inappropriate comments.
2. Causes harm to minors.
3. It interferes with the privacy and individual and social rights of other users.
4. Advertises products or services or websites.
5. Contains personal information (address, phone, etc.).