Command Line Tip – pushd & popd

Posted on 7th February 2011 in Something Daily

I learned a fun command line trick recently. I typically use cd to change the working directory, which is great, but I’ve found that a lot of time gets wasted if you need to frequently move between two or more directories – you have to type the path every time you want to switch, which adds up to a lot of typing. I discovered pushd and popd, which place your directory changes into a stack, allowing you to recall your directory history in a last in, first out configuration. For example, I’m in ~/Music/Gang Starr/Step In the Arena and I want to go to /usr/bin. I type $ pushd /usr/bin (the $ indicates the command prompt), and my working directory is changed to /usr/bin. From there, I want to work in /mnt/mac/Users/emmettbutler/Documents, so I again $ pushd /mnt/mac/Users/emmettbutler/Documents. Then, I want to go right back to the Gang Starr directory without having to type the whole thing – I just $ popd and I’m in /usr/bin again, then $ popd once more to get back to ~/Music/Gang Starr/Step In the Arena. The last item to be pushed onto the stack is the first one to be popped off. Neato!

I spent a really substantial amount of time today working once again on my long-term Java game project – it was the first day of real work on it since early November. I’ve made a bunch of decisions that should help to significantly decrease the amount of manual labor I’ll have to put into the project; namely, I was originally going to have several levels with giant, independently drawn maps, and part of the reason I stopped working that way was because I realized that I don’t have the necessary means or drive to do that much 8-bit drawing. So the new strategy for “level design” is that there will be no distinct levels in a setting sense, just a randomly ordered series of single-frame panels with stars, asteroids, planets, spaceships, and the like. The combat will now be wave-based, with increasingly diverse waves that get harder to kill over time. Those two decisions alone, along with the choice to randomize the settings and precise configurations of each wave, have both eliminated a lot of the work I’d been anticipating and added a lot of potential replay value. If my vision for the random waves is realized, it’ll never be the same exact game twice, but it’ll have the same general difficulty curve each time. It’ll be good. So the work I completed today was the drawing of about 20 background panels and the coding necessary to loop and randomize their scrolling motion downscreen. I also cleaned up some of the parent classes that I wrote back when I was just learning Java. That’s a funny thing about this project, it’s spanning a long enough amount of time that my knowledge base is changing significantly, and my code often has to update with it. But with this new plan laid out, I feel optimistic about the end-of-semester prediction.

I found out today that Jim James of My Morning Jacket and M. Ward of She and Him have a blog dedicated to creme brulee entitled the Cremebrulog. The mere fact that such a site exists is awesome. And it really makes me want some creme brulee.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Comment

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>