OS X Leopard command line tips and tricks

The default shell for Leopard users is Bash. Although many GNU/Linux users are familiar with it, not all Mac users take full advantage of its power. Here are some very useful commands and tips I use routinely.

Users and login

Use the root superuser

sudo su -

Alter login variables (such as $PATH, $EDITOR)

nano ~/.profile

Other available shells

  • /bin/ksh
  • /bin/tcsh
  • /bin/csh
  • /bin/zsh

Files management

Output the contents of a file

cat /some/thing

Get 20 lines from the end of a file

tail -n 20 /some/thing

Get the first 20 lines of a file

head -n 20 /some/thing

Create an empty file

touch /some/thing

Redirect the output of a command to a file (overwrites)

command > /some/thing

Redirect the output of a command to a file (appends)

command >> /some/thing

Append the timestamp to a file

touch /backups/backup_`date +%s`.txt

Change to the last directory you were in

cd /var
cd /etc
cd - # will take you to /var

List file size in human-readable units

ls -lh /dir/or/file

Available editors

  • /usr/bin/vi
  • /usr/bin/vim
  • /usr/bin/nano

Applications and processes

Run a process in the background

command &

List running processes

ps ax

The first column will be the PID

Kill a process by pid

kill -9 <pid>

Kill a process or processes by name (e.g: the Dock)

killall Dock

Open an application (Mac-only)

open /Applications/iTunes.app/

This post has 1 response

How to install Lua 5 in Mac OS X Leopard

Open up terminal. Copy the link of the latest Lua version and download it:

cd /tmp
wget http://www.lua.org/ftp/lua-5.1.4.tar.gz

Extract and compile:

tar -xzvf lua-5.1.4.tar.gz
cd lua-5.1.4
make macosx

Test and install (if test goes through)

make test
sudo make install

And you’re done!

This post has 9 responses

Nicer Google Gmail Notifier Icons

  • red_preview
  • blue_preview

If you hate the default icons as much as I did, you’ll be relieved. I took chris.ivarson beautiful Gmail icons and adapted them for the OS X Leopard toolbar.

Click here to download the replacement icons, and read the INSTALL file for instructions (downloaded 2487 times).

This post has 16 responses

Great mac app: On the Job

otj_icon_large

As a happy Overflow user, I was pleased to see Stunt Software was also into the invoicing / time tracking applications business.

I tried a number of online alternatives to solve this problem, none of which satisfied me (including the popular Harvest and TickSpot). The simplicity and beauty of On the Job is just what you’d expect for an application that will be assisting you on a daily basis with your work, without getting in your way.

This post has 1 response

Twitterrific improvement ideas

The following 3 pictures are humble suggestions to the Twitterrific application, the well-known Mac Twitter client. They depict the ‘active’, ‘inactive’ states, and the third is a concept for a potential Search feature.

  • twiterrific-1
  • twiterrific-2
  • Search state

A summary of the changes:

  • White, centered title instead of the yellow one
  • Less cluttered bottom part: a single button, more writing real estate
  • Retweeting feature and icon. Maybe the button of the user webpage should go too, so that only Reply and Retweet stay, which are message actions.
  • Search feature. Upon pressing Command + F, the message input goes away and is replaced by search.

This post has 2 responses

Safari 4 Beta Review

As a Leopard user, I decided a long time ago that Safari would be my Internet browser, whereas Firefox would be my Development browser. The main reason for this was that Safari has historically had an extra care for the UI, which made it better as an everyday use mac application. Today I downloaded the new beta which takes this to the next level.

I’ll review the key new features of Safari 4 next.

Continue reading

This post has 11 responses

Posted in Desktop about 1 year ago

Make Safari create new tabs instead of new windows

Hate those _target=blank as much as I do ? Just run this command

defaults write com.apple.Safari TargetedClicksCreateTabs -bool true

Via: p@rrish blog

This post has 3 responses

Get hex color codes in OS X color picker

Not only a great addition for any web developer, but also an open source project! Thanks Jesper for this great Hex Color Picker extension.

picture-2

This post has 1 response

A TextMate plugin everyone should have

It’s called MissingDrawer. It replaces the awkward-looking TextMate drawer with a beautiful panel for listing files.
MissingDrawer screenshot

This post has No responses

Set up the perfect OS X browser testing environment

picture-1

If you’re an OS X user and a web developer, you know how difficult things can get to test your websites or scripts on Windows browsers. Some of the alternatives you might be familiar with are:

Each of them has its disadvantages. The first two involve purchasing software (and the OS, if you don’t have it), and the third can turn out to be slow, crash or provide a different browsing experience.

After watching the screencast by Jeff Couturier I finally achieved the cross-browser, cross-platform testing Nirvana. Here’s how

Continue reading

This post has 4 responses

Posted in Desktop about 1 year ago