Posted on 9/9/08 by
Felix Geisendörfer
Hey folks,
here is a word of advice if you want to have more fun developing. Use the terminal. Windows user? Make your next machine a mac (or install linux).
Ever since I switched from Windows to OS X in last July, I have been working on my bash skills on and off. Every step of the way I learned tricks that save me valuable time on a daily basis now. Now it just simply hurts to watch people who avoid the terminal work. Take creating a new database and importing some sql into it. The typical GUI workflow for this is:
- Open a MySql client (PhpMyAdmin, Navicat, ...)
- Click somewhere to create a new database
- Type in the db name (mouse -> keyboard switch)
- Click somewhere to get an import sql dump dialog, often this is hidden in sub-menu (keyboard -> mouse switch)
- Browse to the location you need to find your file
- Select the file and hit enter
- Sometimes now you have to confirm the import again
- Done
If your sql file is compressed and your client doesn't support that compression you will even have to manually uncompress the file somewhere along the way. My typical experience from watching people going through the GUI way of sql import is that it takes them 5-10 minutes.
Now lets look at the bash side of things.
- Cd into the directory with the sql file
- Run the following commands:
mysql -e "CREATE DATABASE foo;"
bzcat foo.sql.bz2 | mysql foo
As you can see, the terminal way of doing this is a lot more efficient. Not only that, your also usually have less problems with it. Because the further you get away from the terminal the more tools and applications are usually stacked on top of each other to make for a GUI app. That usually leads to more bugs and slowness. Especially importing large sql files (I used to import ~2-3gb of data on a regular basis for a client) is something where GUI apps have failed me big time in the past.
Another big advantage of doing things in the terminal is that you can replay them easily. Any decent terminal will or can be brought to record the history of the commands your enter. Check out your shells history commands. If what you did fails, you can easily try again by executing one of your previous commands again without having to type it in (arrow key up). Using a GUI you will have to manually go through all the steps involved again.
Here is another command I use a lot - emptying a CakePHP app's cache directory:
find app/tmp -type f | xargs rm
Anyway, my point is not that everything should be done in Terminal. In fact, for most things I like to have a GUI. But anything that looks like something you might end up doing a lot or that you are likely to do a lot more if it wasn't as much of a pain as it is right now - consider figuring out how to do it in the terminal.
-- Felix Geisendörfer aka the_undefined