What was that macro?
I find myself asking this question a lot: "Now what was that define that detects annoying platform that makes porting otherwise perfectly-portable code difficult?"
This will narrow your search down to something useful:
echo | cpp -dM
Go ahead, try it. I wish I'd known this one earlier.
OS X Terminal Emulation Woes
OS X's Termina.app is the terminal I've been using since I switched to Leopard, because it has tabs now and it's beautiful. Oh, and iTerm gave me too much grief with odd, illogical and unpredictable bugs.
One of the drawbacks to Terminal.app is that it's broken. This is what Aptitude looks like with TERM=xterm (I think this is the default):

This is what it should look like:

How to get from there to here? The short answer is to choose dtterm as your terminal emulation (in Preferences, on the Advanced tab).
The long answer is that the problem here is that xterm supports this capability called back-color-erase (bce). If you tell programs that you are an xterm (with TERM=xterm), they will assume you support bce. The same goes for rxvt and xterm-color and even vt100 (even though that one doesn't seem to support color). bce isn't the only problem, either. There's also redraw problems that are difficult to show with a screenshot.
Setting TERM=dtterm seems to get rid of at least the major breakage. It would seem that the actual capabilities of Terminal.app are closest to dtterm, or at least closer to dtterm than to xterm or rxvt. It solves all the issues I've been having with aptitude, mutt, and screen locally and on remote linux boxes. But there's a caveat—not all remote systems will have the dtterm entry in their terminfo databases. Ubuntu 7.10 didn't by default, for example. The package you want on Debian-based systems (like Ubuntu) is ncurses-term.
Alternatively, you can install it in your home directory. To do this, on OS X type
infocmp > /tmp/dtterm
scp /tmp/dtterm username@example.com:/tmp
ssh example.com tic /tmp/dtterm
tic (terminfo compiler) will create a terminfo database entry in ~/.terminfo/d/dtterm, and you should be good to go.
gvim on OS X
In spite of being the author of one of the more (in)famous vim color schemes, desert.vim, I have been vimming primarily in the console for quite some time now. The primary reason is that gvim on OS X sucks.
Still, it's nice to have gvim working for various reasons. One of the more important reasons is dragging stuff to the Vim icon on the dock.
As a follow-up to my post on unicode in the terminal, I decided to install the latest Vim.app from macvim.org and see how it handled unicode. It didn't handle it very well, but it's only a few settings away.
First, there's the issue of font. I don't like Monaco very much. I use
Anonymous for the terminal
and I think it is an excellent font. In fact, I find myself likeing Anonymous
just as much as Terminus, but it
has the added advantage of being TrueType and looking great with antialiasing.
Unfortunately, in Vim at least it looks terrible without antialiasing. So I
got the pseudo-TrueType Terminus
font by Eric Cheng. It took
some fiddling, because of various Bad Things™ happening with Vim and OS X
dealing with a TrueType-wrapped bitmap font, but I found the following settings
work great (put them in ~/.gvimrc):
set enc=utf-8
set macatsui noanti gfn=Terminus:h12
It's not antialiased, but it is Terminus and it handles Unicode just fine (as far as the Terminus font itself does, which is pretty good).
You can use antialiased fonts, e.g. Anonymous, with the following .gvimrc:
set enc=utf-8
set nomacatsui anti termencoding=macroman gfn=Anonymous:h10
but Bad Things™ happen when you use Unicode, so I'm sticking with the Terminus setup.
Posted in mac | no comments |
MacBook
My GAANN fellowship provides me with a laptop, and that laptop has finally arrived. It's a MacBook 13" and it's very nice. Unfortunately the University claims it as its own because it was bought through them and was over $1k, so I will have to give it back when my GAANN stint is over. Hopefully that means when I graduate, but if our department doesn't get the GAANN award that it's applying for that means GAANN is kaput next August. So I'm keeping the iBook in cold storage and we'll cross that bridge when we come to it.
In the process of setting up my essential applications I discovered a few had been updated without telling me, and I took the chance to investigate some alternatives to the programs I wasn't fully satisfied with. iTerm was updated, and actually has a useful release now. It looks a little nicer, seems to behave better, although I've come across some glitches when it's set to always show tabs. I skipped the space-consuming menu bar system monitoring stuff that I had on the iBook and gave iPulse another look. Last time I was turned off by the clown colors and that it was hard to see what was going on. This time I was looking for succinctness and was willing to invest some time in learning to read the display, and I tried out a few of its jackets (I settled on Doppler), and I'm quite pleased. It also has a menubar display that's much more relevant and compact than what I was using, as well as an animated dock icon. And it doubles as an analog clock down there in the corner. I'm very impressed.
I am disappointed, however, in the video card. Flightgear still runs at a crawling 7fps sitting on the runway at KSFO with the default settings. I might be able to get it running at a suitable speed, but based on this experience this Intel GMA 950 card is nothing like the NVidia Quadro4 in my desktop. Flightgear on the iBook worked fairly well in Linux, so I'll try that out when I get Linux installed and perhaps I will be pleasantly surprised. This wasn't to be my primary Flightgear station anyway so it's not the end of the world.
I'll report on installing Ubuntu 6.10 when I get around to it in the next few days.
Posted in mac |
Firefox, Close Thyself
Firefox 2.0 is pretty slick, but one thing really bugged me. When you close the last tab with command-w, the window stays there. I thought, "hmm, maybe this is a feature not a bug so I'll try it for awhile and maybe I'll like it." I didn't like it. Luckily the fix is not hard. Just uncheck "Always show the tab bar" in the tab preferences pane, and sanity will descend upon your zorro. This is of course completely illogical and uncalled-for. Heck, even an entry in about:config would be better (yes, I looked there). But at least it's controllable.
Annotating Plots in Octave
In MATLAB, you can do this:
x = 2*pi*[0:100]/100;
figure(1); plot(sin(x));
figure(2); plot(cos(x));
% ...
figure(1); title('sin(x)');
figure(2); title('cos(x)');
In Octave on OS X, I was having trouble. There were two problems. First, the version of Octave I had (2.1.73) had a bug where it would not just add the title "sin(x)", but replot the current plot (the cosine) and give it the title "sin(x)". Not what I wanted. I upgraded to 2.9.9 and it now works properly provided you solve the other problem.
The other problem is more a misdocumentation. The docs for figure.m read:
Set the current plot window to plot window N. This function currently requires X11 and a version of gnuplot that supports multiple frames. If N is not specified, the next available window number is chosen.
figure is the user-defined function from the file
/usr/local/share/octave/2.9.9/m/plot/figure.m
But if you look at the source it's obvious that it works with AquaTerm as well,
but only if the environment GNUTERM is set to aqua. So put this in your
~/.bashrc:
export GNUTERM=aqua
On Linux, running a version of Octave without the bug mentioned above would be sufficient, as you're obviously running X11. I have gnuplot version 4.0.
VirtueDesktops
For almost a year and a half I have used OS X as my primary user interface. I don't switch back to Linux for the ironic reason that keyboard shortcuts are more useful and usable in OS X. But I've always missed virtual desktops, until now.
I always figured it really couldn't be all that hard to do this right, and it boggled my mind that nobody ever did. I tried a few that didn't do it right, and doing it wrong is worse than not doing it. But VirtueDesktops does a fantastic job. I can lay out my desktops in a grid, I can use the keys I want to use to switch, and if I switch applications I'm taken to the desktop hosting that application. It's perfection. Finally.
macirssi
Ok, scratch that part about Irssix. Irssix is cool but has some issues:
- pgup/dn don't work from the input box
- it automatically scrolls down when something new happens, making it really difficult to read backlogs. (I hate it when my terminal does this too, btw)
- it tends to crash when reconnecting after waking my laptop
But macirssi is even better. It does let me change the font, already comes with a dark background, has more preferences to set graphically, and doesn't crash. It does look a little funky, though (as in not really OS X-ish).
Pasting Panacea
Pastie is the paste site I've been waiting for. Simple, elegant, useful, fast. Now, I've gone a step further and (re)written a shell script to paste from stdin and give you the URL:
#!/bin/sh
curl http://pastie.caboo.se/pastes/create \
-H "Expect:" \
-F "paste[parser]=plaintext" \
-F "paste[body]=<-" \
-s -L -o /dev/null -w "%{url_effective}")
But that wasn't far enough. I went one step further and made an OS X Automator
workflow to take what's on the clipboard, paste it to pastie, and put the
resulting URL on the clipboard. Throw
Pastie.app in ~/Applications and
you can use Quicksilver for the perfect
instant pasting panacea.
FileMerge
OS X has this nifty utility called FileMerge which is far and away the best way to merge differing files that I have ever seen. Yes, that includes vimdiff, although a sufficiently large gvimdiff is pretty good too. If you give it a try, don't give up saying "too much mousing" until you've explored the (mostly hidden) keyboard acceleration. I found sensible accelerators for every function I hoped for.
Bruno De Fraine has
gifted us with a set of bash
scripts to use FileMerge as
Subversion's --diff-cmd and --diff3-cmd. This means when you have a
conflict in Subversion you can merge with FileMerge. Along with the [helpers]
section in ~/.subversion/config you can be in FileMerge/SVN paradise.
I intend to figure out how to get this working with darcs soon. Actually I've found some pages about it that don't seem to work with my current version of darcs. When I get more HDD space I can install that silly Haskell compiler and upgrade, then I will report if it works.
Posted in cs | no comments |
Older posts: 1 2