Posts tagged with “”

Tab Completion for CDPATH on Mac

Though I’ve written several shell-related posts, I’m not a shell geek. Let’s get that out of the way right now. The shell is a tool for me and nothing more. I had used tcsh for years and years and years for no other reason than someone told me it was better than bash when I first started doing any “real” Unix work. I recently moved to bash because, frankly, I was tired of having to custom-configure every system I login to on a regular basis. Bash is the default shell for most Unix flavors and since the shell is only a tool, I saw no reason to continue spending time on customizations.

The other day when @patrick_mc dropped a link to a bash mastery article in a tweet, I saw the opportunity to learn something. Though it was hardly a masterful type article, I did learn about one thing that I didn’t know about before: CDPATH.

The details of CDPATH are outside of the scope of this post, but the gist is that it works the way that the PATH works. Type a directory and if it’s in your CDPATH, the OS will find it and change to that directory by name alone – even if the directory name isn’t in your current working directory. For example, if I’m in my home directory, I can type www and be delivered directly to /Users/me/Development/www as long as /Users/me/Development is in my CDPATH.

When I first read the article, I was at work and on my Ubuntu machine so I tried it there first by adding the following line to my /home/me/.bash_profile:

export CDPATH=.:~:~/Development

After sourcing ($ source .profile) my updated profile, I was able to jump to directories exactly as advertised. Moreover, tab completion worked brilliantly so, from my home directory, I could type cd w[TAB] and it would complete to cd www. Brilliant.

It wasn’t quite so easy on the Mac, though. I updated my .profile, but couldn’t get it to work. I thought I had a syntax error in my .profile, but after hours of trial and error, I was no closer. I pinged the #lazyweb on Twitter to ask whether it worked for others on OS X and got more than a few affirmative responses which just confused me even more. A quick chat with Brad Greenlee, though, pointed out the error of my ways. It turned out that CDPATH was working great, but I was assuming (yeah, I know) that tab completion would also work. It didn’t.

For me, something like CDPATH is only useful with tab completion because otherwise, I can tab complete the full path to the file before I can type the entire directory name (for all but the shortest directory names). Besides, the Tab key is completely woven into the fabric of my muscle memory now. I can’t give it up when I’m in the shell. After a little digging, I found the answer:

$ sudo port install bash-completion

Yep, that’s it (assuming you have MacPorts installed). Well, almost. You do have to update your .profile (or .bash_profile, .bashrc, etc.) to source the installed file at /opt/local/etc/bash_completion. Instructions for doing so are printed in the output of the installation. In case you close your window too early, though:

if [ -f /opt/local/etc/bash_completion ]; then
    . /opt/local/etc/bash_completion
fi

Happy completing.

Remove Conflicted Files from Dropbox

Because I use Dropbox to share selected runtime data (read: Firefox profile information) across machines and because I occasionally forget to exit the runtime environment (read: Firefox) when I move between those machines, Dropbox creates conflicted files from time to time. The conflicted files are saved separately and are named something like this:

places (my.machine.name's conflicted copy 2008-11-13).sqlite

The file above is my Firefox bookmarks database. I have no idea how it came to be in a conflicted state, but the ugly truth is that I don’t care. I assume that Dropbox saves these files as a safety measure against losing their customers’ data and so that the customer can perform a diff on those files if they choose. I don’t choose. I keep convenience files in my Dropbox, not critical files, so the files themselves are not worth the effort it would take to find and evaluate the delta between the “good” file and the conflicted file.

To that end, I’ve taken to simply removing them and because I don’t want to browse the directory structure or do this in any other manual way, I let my operating systems do the work for me. This is easy in Unix and, since two of my machines (my two primary machines) are Unix-based (OS X and Linux), it’s easy for me:

$ cd ~/Dropbox
$ find . -type f -name "* conflicted *" -exec rm -f {} \;

Poof. Now they’re deleted and Dropbox will delete them from my Windows boxes for me. I’m sure that there’s a way to do something similar on Windows, but my DOS skills atrophied many moons ago.

Ars Technica's Look at the Windows 7 UI

And, just to be fair in my critique, it looks like Windows 7 might also fix one of my long, long, long, long time annoyances with Windows itself – its system tray.

By default, new tray icons are hidden and invisible; the icons are only displayed if explicitly enabled.

I’ve moved off of Windows as a day-to-day platform and don’t plan to return, but these are big steps toward a decent user experience. Kudos to Microsoft for really considering that aspect and working to improve it.

Snow Leopard vs. Windows 7

One thing I’ve never gotten used to, or learned to like, with Mac is its inconsistent and inexplicable approach to window sizing.

Microsoft took the time to explain some new features of Windows 7 to us. There have been a couple of user interface enhancements. You can now resize Windows by dragging them to edges of the screen. Top to maximize, bottom to minimize and dragging to the left or right automatically resizes to half the display. If you’re comparing documents side by side you can just move the documents to the left- and right-hand sides to automatically fit both on the screen.

I really like the the approach Microsoft is trying to take and, from the description, the gesture seems perfectly intuitive. The optimist in me feels sure that Apple can see the benefit of consistent, intuitive and just plain sane window sizing. Can’t they?

Gizmodo has its own review of the Windows 7 UI improvements including a video showing the new window resizing feature in action.

Macworld's First Look at the New Macbooks

The Energy Saver icon used to be an incandescent light bulb; Apple has replaced it with a compact fluorescent as a part of its quest to reduce the energy consumption of its icons.

I’m a little underwhelmed, myself. There are some things that I like and some things that I don’t. The things that I like aren’t compelling enough to make me run out and buy one and the things that I don’t offer compelling reasons not to do so.

I like the multi-touch trackpad, the stylings and the magnetic “latch”, but I’m not a fan of the glossy screen that’s now the only option or the fact that I can still get no better than 1440×900 resolution on the 15” Macbook Pro even though they have the snazzy new video card. I’m also a little ambivalent about the zero-button trackpad. It seems like a recipe for inadvertent clicks, but I have no hand-on experience to support that. Right now, it’s just a potential concern.

I’ve actually been holding off on the purchase of a new MBP because I wanted to see what the new line had to offer, but I think I may wait a little longer. I haven’t seen anything that makes me want to rush out and buy.