9.28.2007

Getting Terminal to be More Usefull

One of the most befuddling things about using Mac OS is the lack of a terminal emulator that works well out of the box. I've never even thought about configuring a terminal aside from fonts and colors before, so the idea of having to tweak settings to get it to behave properly was initially confusing. I'll show you how to get Terminal.app to behave the way you would expect it to.

Get Delete to Work All the Time:

To get delete to work in utilities like sftp, ftp, etc, run the following command locally (That isn't a literal ^H, you type that character by doing 'ctrl-v' and then 'ctrl-h'):

echo stty erase ^H >> ~/.profile

And now you can source ~/.profile, and you should be set.

Get PgUp, PgDn, and Alt to work:

Bring up the dialog to configure the terminal by right-clicking (or ctrl-click) the terminal window, and click on 'Window Settings'. Most of the things here a fairly obvious, so I'll leave it up to you to play around with them. What we are concerned about is under the "Keyboard" section:
    • Turn on "Delete key sends backspace"
    • Enable "Use option key as meta key". This will enable things like "alt+b" to go back a word, and "alt+f" to go forward a word.
    • look for the key-binding for 'page up' and edit it. Change the action to 'send string to shell', and in the text box, hit escape (it will show up as \033), and type "[5~". Do the same for 'page down', but type "[6~" instead. This will enable page up and page down to work inside of a pager or an editor.
Launching X11 apps from Terminal, and ditching xterm:

I don't like to use X11 on Mac OS, but sometimes I have to. When I do, I'd rather launch it in the background, and start applications from Terminal.

Put the following in ~/.profile:

export DISPLAY=:0.0

now make a .xinitrc file:

echo "exec quartz-wm" >> ~/.xinitrc

Now when you launch X11, it will only start a window manager, and not xterm.

Launching Mac Apps from Terminal:

You can launch a Mac application by running "open -a AppName". In ~/.profile, I like to add a few aliases:

alias hexedit="open -a 0xED"
alias edit="open -a TextMate"

Now you can edit a file with 0xED by running "hexedit filename". You can do this for almost every Mac app. If you have a file with an extension (like .doc, or .torrent), you can just ask Mac OS to use the appropriate App by running "open filename".

Scanning for Wireless Networks from Terminal:

If you find yourself missing iwconfig in linux, or the wireless extensions of BSD's ifconfig, then you will probably like this. The normal wireless applet is good enough for me most of the time, but it doesn't tell you if networks are encrypted or not, you can get this information in a terminal.

There should be an executable at:

"/System/Library/PrivateFrameworks/
Apple80211.framework/Versions/A/Resources/airport"

You can alias this to "airport" in ~/.profile if you like. You can list the available options by running it with "-h". My favorite option is "-s", which lists all of the APs and information about what kind of network they are running on.

Thats it for now. All but the first two sections should work in iTerm as well. I personally think that iTerm over-complicates a relatively simple thing, so I'd rather use a tweaked Terminal.

9.04.2007

Mac OS from a Unix Point of View

I've used some form of "unix" most of my life. Recently, my finance bought me a little black MacBook laptop. It is far from flawless, but very impressive. I do not consider myself a convert, I would be just as happy running a laptop with FreeBSD or Linux. So hopefully I will give a fairly unbiased view of what it means to be a Mac user. I use this laptop as my main computer, and I've never really used windows for anything for anything, so this has forced me to find alternatives to all of my beloved Linux apps. Later I plan on documenting the specific details about how I deal with using OS X.

Hardware:
The best thing about owning a Mac is the amazing hardware that goes with it. The simple, elegant, black laptop is why I decided to get a Mac. I figured if I didn't like OS X I could always throw Linux on it. I will probably never exclusively use OS X (I am dual booting at the moment), but I don't think I will ever buy a laptop from any other company. It is solid, beautiful, and fast. And as a safety net it runs Ubuntu very well.

GUI:
The main difference between OS X and any other unix-like operating system is the GUI. You probably know that Mac OS doesn't use X11, it uses something called Aqua. The differences between Aqua and any other window manager cannot be explained, they must be experienced. You cannot make Aqua behave how you want it to, you must learn to like how Aqua behaves. You can run X11 applications in aqua, but X11 does not integrate well, and is very buggy at times. Do not buy a Mac under the assumption that you can have a fully featured KDE/Gnome/FVWM desktop and Aqua at the same time, and I would even say that you shouldn't count on your graphical linux/bsd apps working well either. They will stick out like a sore thumb, not only in the visual sense but in terms of how they are used.

Another thing worth mentioning is font rendering. I eventually got used to Mac OS's font rendering, but at first I thought it was hideous. The problem seems to be that Apple values the parameters specified by the font designer more than they value aligning fonts to the pixels. So the same letter might appear slightly different based on where it appears on the screen. I guess this is good for documents that will eventually be printed, but less desirable for code or a terminal.

APPS:
The program's that ship with OS X are mostly just amusing. They are fun, but eventually you have to do something other than take pictures of yourself and make comic books with them. One thing I really miss when using OS X is having a good selection of free applications that work well. Here is a breakdown of some of the apps that I've messed with, most of the ones I've listed are free:
  • Fan Control
    • the app is called Fan Control. It lets you adjust the fan speed. Macbooks run to hot for my lap without cranking the default speed up to 3500 rpm ( I don't know why it imposes this limit, in linux it can go up to 6000). There is no /sys, /dev, or /proc entry to let you do this yourself, so this app is a must if you want to crank up the fan.
  • Browsing
    • I use a combination of Safari and Firefox. There are some features of Firefox that I just cannot live without, but the Mac version of Firefox just plain sucks. It is slow, unstable, and many of the extensions don't play nice.
  • Editing: I mostly edit Python and C source code, so take my opinions for what they are worth. If you like to edit files over ssh or ftp, there are no good free options. Your best bet is to use the port of SSHFS from Google labs, and pretend its a local file.
    • TextWrangler: The best free (as in beer) gui based option for editing. There is nothing particularly amazing about this editor. I suppose it looks nice, for whatever its worth.
    • TextMate: this is by far the best graphical editor on Mac OS. You have to pay for it. It isn't really that much better than Gedit or Kate with a couple of extensions enabled, but given the competition it is easy to see why people pay for this.
    • Emacs, Vim, Pico, Nano, etc: They are all there, and they all work. If you edit from a terminal Mac OS should not be a problem for you.
  • Bittorrent:
    • Azureus: if you like this client, you'll feel at home. I don't like it, but many do so I thought I would mention it
    • Transmission: This is the best BT client I could find. I actually started using the Linux version after trying the OS X version. It is like Ktorrent, only not as powerful, but it meets my needs.
  • File Sharing:
    • Limewire/Frostwire: This is the client I use in Linux, the Mac version is alsmost the same, I don't really see a need to look any further.
  • Hex Editing:
    • 0xED: hands down best hex editor for Mac OS. It is pretty much the same thing as ghex2 or khexedit. You have to highlight something before it will give you the integer/long/float/double value of it, which I found confusing and pointless since those things are all of a set size.
  • FTP/SFTP Transfers: if you use Konqueror or Nautilus, you take these things for granted. Any computer on the network is just as transparent to you as the one you are sitting at. Sadly Finder (The OS X File Manager) is a worthless piece of crap. There are only two decent options that you don't have to pay for:
    • SSHFS/MacFuse: the ssh filesystem from Google. It allows you to mount remote machines over ssh. This is no where near as stable as the Virtual filesystems offered by both KDE and Gnome.
    • ftp/sftp: yep, the command line utilities. I use these because there is no other sane choice for basic file transfers. This doesn't work out all that well for running a local editor and doing remote development tho.
  • Movies: I am sad to say that all of the video playing/editing software that comes with a mac sucks. I still reboot into linux to use Devede to make video DVDs. iDVD and iMovie have nice interfaces, but they are always crashing on me, and don't give you much control. They only seem to be good for editing a short home video, not ripping a DVD or encoding a full length movie into a DVD.
    • VLC: Pretty much the same thing as its Linux and Windows versions. I use this because it is the only thing that plays everything I throw at it.
    • Mplayer: The linux version compiles on OS X just fine. I use this for mencoder, which is nice for re-encoding videos.
  • Music:
    • iTunes: It plays music. It is nowhere near as cool as Amarok, and it doesn't sync up with my Sanyo mp3 player like Rythmbox. I have no desire to buy an iPod, so I guess I'll have to reboot into linux to use my mp3 player.

Thats it for now. Stay tuned for more specific hints and tips about using a Mac.