Entries Comments



Category: Mac


Use vi key bindings in bash

3 December, 2008 (22:29) | Coding, Linux, Mac | By: benjamin

A long time ago I used ksh with vi key bindings, and life was good.

Then I moved on to bash, but for some reason, I never investigated using vi key bindings. I simply lived with the defaults (which, for the record, are emacs-like key bindings).

So, just the other day I said to myself, “Self, I want to use vi key bindings in bash. I want to again experience the joy of traversing and editing my command line in COMMAND MODE. I want the speed and the power of my precious vi (well, I use vim) at my finger tips. And I NO LONGER want to waste time holding arrow keys or to think about using emacs-like commands.”

So, I fired up google.com; low and behold I stumbled onto this little post about using vi key bindings in bash and zsh. So sweet!

In a nutshell, the bash command to enable vi mode is:

set -o vi

This can be set in your .bashrc file, and if it doesn’t pickup when you start a new terminal session, add something like this to your .profile or .bash_profile:

if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

With vi mode enabled, you’ll start your bash session in insert mode, so things should behave as normal. But, to turn on the power, just hit the ESC key to enter COMMAND MODE. :) Now all your vi commands are availble. Move to end of line with “$”, beginning of line with “^”, delete a word with “dw”, etc.

Enjoy!

Bonjour Avahi Addendum

6 November, 2008 (09:23) | Linux, Mac | By: benjamin

A while back I wrote about advertising Linux services via Avahi/Bonjour. Since then I’ve made a few changes to my setup.

First, I nixed netatalk for direct AFP support. My primary reason for using it was to gain a more Mac-like network filesystem which would make Time Machine happier. Well, Time Machine uses a sparse bundle disk image on it’s target; after learning about that, using AFP seemed a bit unnecessary. Also, Samba CIFS/SMB seemed to perform better. I don’t have solid benchmarks for this, but simple file copies seemed to be consistenly faster with Samba. One of the biggest annoyances about netatalk was all the extra hidden files and folders it created. I run a hybrid network, I have more Mac machines, but also Windows, plus I browse file systems on the command line quite often; and those excess files pushed me over the edge.

Second, I nixed Time Machine. Just when I thought everything was working perfectly, it completely blew up and could no longer access its data store. Not good for a backup solution. I plan to write about my new home backup solution sometime, but it’s basically rsync with a few key points.

Lastly, I streamlined my Linux avahi config using some pointers here, suggested to me by George the commenter on my above linked post.

Previously i had a service config file for each service, but this resulted in my server having multiple entries in the OS X Finder, one host for Samba, one host for AFP (when I had it), and one host for RFB. So, I merged all of those files into one.

multi.service

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h</name>
<service>
<type>_smb._tcp</type>
<port>139</port>
</service>
<service>
<type>_rfb._tcp</type>
<port>5901</port>
</service>
<service>
<type>_device-info._tcp</type>
<port>0</port>
<txt-record>model=RackMac</txt-record>
</service>
<service>
<type>_http._tcp</type>
<port>80</port>
</service>
<service>
<type>_ssh._tcp</type>
<port>22</port>
</service>
<service>
<type>_sftp-ssh._tcp</type>
<port>22</port>
</service>
</service-group>

Now everything that can show up in the OS X finder, shows up on one host entry. Plus thanks to the tip I linked to above, the “_device-info._tcp” section sets an icon for the server in OS X Finder.

Enjoy!

A Project Idea: iPhoto to Wordpress [gallery] Export

22 October, 2008 (22:52) | Coding, Mac | By: benjamin

I’ve been spending some time getting my son’s blog setup. In doing so, I discovered that as of Wordpress 2.5, there is built-in [ gallery ] functionality.  Though it isn’t full featured, it’s pretty nice, and perfectly integrated with Wordpress, since, well, it IS Wordpress.

Currently the process to put photos into a gallery is:

  1. Choose photos in iPhoto
  2. Export chosen files to disk
  3. Create new Wordpress post
  4. Add media via Wordpress uploader

This isn’t too bad, especially for a geek who’s used to lots of arcane workarounds to accomplish simple goals. But… for my wife or others who don’t want the hassle, this is basically annoying.

So I have this idea to create an iPhoto export plugin which will upload directly into Wordpress!

Roadblocks to completion:

  1. Time and Commitment (typical)
  2. Objective-C (don’t know it)
  3. Cocoa (don’t know it)
  4. X-Code (don’t know it)
  5. Non-Javascript/Java development on Mac OS X (new to me)

So… this is going to be a slightly ambitions undertaking… but I’m excited about it! I’ll be learning a bunch of new stuff. It’ll take more time than I’d like, but I expect it to be a rewarding process. At some point, I’ll be able to create a “project” home for this bad boy, and make it available to all!

If anyone has pointers on OS X development, I’m all ears. :-)

Fight Back! (When VPN Clients Mis-Behave)

23 July, 2008 (12:20) | Mac, Networks | By: benjamin

I have to use VPNs at work. Specifically, to access my production webservers (etc), I have to use a Cisco VPN client. Sadly, the VPN concentrator overrides my choice of allowing local LAN access. So, when I am on the VPN, I have my DNS options changed so I can’t use any local servers. This is a serious, serious pain. So painful in fact, that many times instead of fight with it, I simply would run a Windows session in VMware (on my Mac) and connect the VPN there. This has drawbacks too, but it’s better than not having local network access.

So I set out to find a solution and I found a post by loudhush which described using the scutil to modify DNS network settings after connecting to a Cisco VPN. This was great, but I needed something a bit handier.

So, I cranked out the following which goes in my /Users/username/.profile:

# .profile or .bash_profile
function myvpn {
vpnclient connect VPNPROFILENAME user MYVPNUSERNAME
myworkdns
}
function myworkdns {
printf "get State:/Network/Service/com.cisco.VPN/DNS\nd.add ServerAddresses * 192.168.1.252, 192.168.1.198\nd.add SearchDomains * example.com, other.example.com\nset State:/Network/Service/com.cisco.VPN/DNS" | sudo scutil
}

These are bash functions which i run from the command line. (I also find the Client GUI Cisco to be a pain, and prefer command line)

So, obviously, you’ll need to substitute in your Cisco VPN profile name ( found in /etc/opt/cisco-vpnclient/Profiles), your VPN username, your DNS server IP addresses, and your DNS search domains to your legitimate values.

To use, run Terminal, then type myvpn. The VPN client will prompt you for your username and password. You’ll then have to hit CTRL+Z to suspend the VPN client so the script can run the DNS updates; this part uses sudo to run the command as root, so you will probably need to type your Mac password immediately after hitting CTRL+Z. If you didn’t want to bother with the command line VPN client, you could just use your GUI Cisco VPN client, then run myworkdns from Terminal, which will still probably prompt you for your Mac password.

Hope others find this useful. If I find a cleaner way, I’ll post that too.

Beating the Cisco VPN Client Error 51 On Leopard

22 July, 2008 (10:10) | Mac, Networks | By: benjamin

I had this error popup today on my Mac OS X Lepopard 10.5.4 machine.

Cisco VPN Client Error 51

This is not cool as, well, I NEED MY VPN TO WORK!

Thankfully google came to my rescue. The solution is to execute the following in Terminal:

sudo /System/Library/StartupItems/CiscoVPN/CiscoVPN restart

Thanks for the answer, VirtuallyShocking.com.

Firefox 3 rc2 Is Out!

5 June, 2008 (10:41) | Mac, Web | By: benjamin

Since moving to the Mac, I’ve tried to use Safari almost exclusively. I definitely like it, and it’s got some great tools, but I usually found myself running back to Firefox 2 whenever I had to really do work on a website because I really like some the power Firefox extensions give me. A couple of the things NOT too like about Firefox 2 was the heavy memory usage, the crashing, and the lack of native Mac OS X widgets.

I’ve been playing with Firefox 3 betas off and on, but yesterday I noticed Firefox 3 release candidate 2 is out! This is likely going to be the last pre-release until the official launch, it has fixed a lot of bugs, and it solves some of my nagging issues. Memory usage is better, crashing less frequent, and we now have native widgets! Of course, I use Firefox for work, so to use FF3 I need my extentions which haven’t all been available till now:

Yesterday I mentioned this to my co-worker who expressed concern about being able to test in Firefox 2. We already have this issue with IE6/IE7 and there’s no good solution for that but to have an extra copy of Windows with only IE6 installed. (yes, you can try weird hacks like this, but they don’t always seem to work)

Well, with Firefox (old and new) there’s this snazzy profile manager tool, which lets you choose what profile you want to use.

First, if you want to have multiple copies of Firefox installed, just name them differently. When you download Firefox the app is named “Firefox” I’m planning to use Firefox 3 as my standard now, so I’ve left it named that renamed my old Firefox to “Firefox2″. Shocking, isn’t it.

Now, from Terminal, I can run the following:

$ /Applications/Firefox2.app/Contents/MacOS/firefox -ProfileManager

You should see something like this:

Firefox Profile Manager

By default, you’ll probably only have the “default” profile, but you can create a profile dedicated to testing in FF2 which should prevent it from screwing with my FF3 profile (as I’ve noticed can happen). Another side effect is that this lets you run multiple copies (of the different versions) of Firefox at once. Also, un-check the “Don’t ask at startup” box, and you won’t have to run the secondary browsers from the command-line to ensure you get the profile you intended.

For the record, I’ve tested the same thing on Windows XP. While you can install multiple copies/versions of Firefox and use the different profiles the same way, you cannot run both copies at the same time. At least I couldn’t make it work.

Plainview: presentations ala web

5 June, 2008 (03:18) | Mac, Web | By: benjamin

I just stumbled onto the coolest little app for Mac. Plainview is a web browser based on WebKit (also the guts of the Safari browser). What’s unique is it’s intended to NOT have chrome (the name for all tose fancy navigation bars, address text boxes, menus etc). It’s slim… so slim the chrome is non-existent. This is a full-screen mode web browser, intended to utilize the full screen real estate for presentations! Essentially, instead of having to take screenshots of websites and put them into power point or something, you can just demo the site. It’s awesome… and i’m not even explaining it as well as they did… but I am tired. :-)

I hope that in the near future I can use this for more than playing around.

Using Microsoft Entourage on my Mac

26 March, 2008 (05:01) | Mac | By: benjamin

I’m not really a Microsoft fan, nor do I consider myself a Microsoft hater. I generally like Linux and free Open Source software, and as a network and software engineer type I really like the power and flexibility of Unix-like operating systems. I made the switch to Mac because I wanted to see what all the fuss was about, and if I would benefit from a “Unix like system that just works.” Though there were a few bumps in the road, I’m pretty happy overall. Sometime maybe I’ll post about my Mac experience and thoughts in a broader sense.

This post is about Entourage. When I started this fall, my employer was using Zimbra for our mail and calendar platform. A few weeks ago we migrated to Microsoft Exchange. As a Mac user, I’d gotten very happy with Mail.app and iCal; suddenly I was in an environment where my iCal couldn’t sync to the server like it did previously with Exchange. The only real solution was to either use the web-based client OWA (Outlook Web Access) or to switch to Entourage. I decided to give Entourage a shot.

Entourage is like Microsoft’s Outlook for Mac. It has most of the same features, but a very different interface.

One of the most annoying things I immediately noticed was the layout of the message list pane. By default there’s a three column view, folders (etc), message list, and message preview pane. I’m ok with this in general, but the message list was not very configurable. Sure you could change how messages were sorted, but the messages were ALWAYS displayed using two text rows, even “conversation” headers with only tiny text like an arrow and the work “mail” used two lines, wasting tons of space and limiting the info and number of messages I could see at any one time. I could change that, but I switched to a two column view with message list above the preview pane. This works pretty well as the messages in the list now only use one line and the columns displayed are fully configurable.

This has seriously been my biggest beef so far, though there are others. But I’m really tired… I’ll come back to discuss the other issues. Bottom line though, since I need some of the Exchange functionality, I don’t have a lot of choices, but it’s not too bad once you get past some quirks.

Advertising Linux Services via Avahi/Bonjour

27 January, 2008 (16:20) | Linux, Mac, Networks | By: benjamin

In my last post I outlined how I followed others’ directions to enable netatalk on Linux and Time Machine backups to a shared AFP folder. Originally, I also described how to put all your shares on netatalk. I suppose if only have Mac clients or you REALLY want to use AFP, you can do so. As I worked with files over AFP shares, I started noticing that the performance seemed to be quite bad. No, I didn’t benchmark, but copying large video files to a shared folder over my gigabit network was substantially slower over AFP (netatalk) than over CIFS/SMB (samba). I use my network shares pretty heavily, so this was a concern. Also, netatalk tries very hard to replicate an HFS filesystem complete with resource fork support. This means that your shared directories end up with lots of extra folders named “.AppleDouble”(and a few others) containing Mac specific info. (Note: even on CIFS you’ll get the “.AppleDB” folders unless you disable a setting in Finder. I can deal with .AppleDB better than .AppleDouble AND .AppleDB) So, because of these two issues I decided to try using CIFS and samba again.

Read more »

Time Machine backup to Linux via Netatalk

24 January, 2008 (01:26) | Linux, Mac, Networks | By: benjamin

So, when I got the upgrade from Tiger to Leopard on my MacBook Pro, I was looking for a good backup solution. I’ve used rsync in the past, but when I saw that Apple had a new Time Machine backup tool, I was curious to give it a shot. The catch is you basically needed an external USB or Firewire drive, until they recently came out with the Time Capsule. Anyway, tonight I got the itch to really see if I could make Time Machine work without buying extra hardware. I mean, seriously, I’ve got a good hunk of mirrored disk sitting on my home server; that seems like a good place to do backups.
Some googling found me this link to a blogger who’d done it!
I’ll make my own version of this post, since I had a few differences from the original I where I found the info.

Read more »