Apple

Bad key bindings over ssh from a mac

I encountered, for some time now, problems when connecting over ssh from my mac to a linux machine.
These problems were related to backspace/delete key in both nano and zsh the solutions I found today are :

For zsh type :

echo "bindkey ^? backward-delete-char" >> ~/.zshrc
echo "bindkey ^[[3~ delete-char" >> ~/.zshrc

WARNING : you should type these commands not copy/paste them, ^? sequence is obtained using ctrl+v then [backspace key].

For nano type :

## Fix Backspace/Delete confusion problem.
echo "set rebinddelete" >> ~/.nanorc

All should works now.

Published on Sat, 23 Feb 2008 20:44

Automount shared directory on Leopard

Following my last post, here’s another handy new thing to do in Leopard. I never used this in Tiger (MacOS X.4) because it was not practical (besides being possible), but I swear it was usable by the time.
Auto-mounting remote shared server (Samba, NFS, AFS) wherever I want, without being stuck with a dead Finder.app whenever I lost wifi network, I change room or my mac goes to sleep (yep I used to have some problems with this).
So now how to do this ? NetInfo is gone so where can I define my automount points, remember when I said NetInfo is dead for the best ?

First, you should edit /etc/auto_master :

sudo nano /etc/auto_master

The stock version should looks like this :

#
# Automounter master map
#
+auto_master    # Use directory service
/net      -hosts    -nobrowse,nosuid
/home      auto_home  -nobrowse
/Network/Servers  -fstab
/-      -static

You need to add a line like this, just before /- -static. :

/my/mount/point/path    auto.smb

Where /my/mount/point/path will be the full path to the directory where remote shared folders will appears. Mine is set to /Users/_myusername_/Desktop/Shares.

Now create a new file in /etc/auto.smb :

sudo nano /etc/auto.smb

And add one line per remote folder you want to mount automatically, each line should looks like this :

www -fstype=smbfs ://username:password@remote_server_name_or_ip/shared_folder_name

www : this is the name you want to give to the remote folder locally

-fstype=smbfs : specify the kind of filesystem to use, I only cover samba here.

://username:passwordremote_server_name_or_ip/shared_folder_name@ : this is the informations to connect to the remote server. Change username and password with yours, specify remote_server_name_or_ip to reflect the way you access the machine and set shared_folder_name to the name of the remote folder.

Then set permission on the new file :

sudo chmod 600 /etc/auto.smb

Now restart automount daemon :

automount -vc

You should see your new mount point as well as stock ones :

automount: /net updated
automount: /home updated
automount: /my/mount/point/path updated
automount: no unmounts

Notice just like /etc/hosts that Leopard seems to only detect a change if a line is added/removed, so anytime you make a change that does not change the line number in the file add a comment (#) at the beginning or end to force a reload.

Published on Sat, 26 Jan 2008 22:28

Hosts aliases in Leopard

Back in Tiger days, I used to love having aliases pointing to localhost or other servers saving me some typing and allowing me to use Apache vhosts locally. To achieve this without restarting the whole system, I used NetInfo to add a new Machine entry, this works great, no restart needed only NetInfo reload.

With Leopard, NetInfo is gone (for the best) and it has been replaced by a folder hierarchy full of flat .plist files. No more NetInfo Manager, but a new dscl command and a bunch of related one : dscacheutil (lookupd replacement), dseditgroup, dsmemberutil, etc.

For today, we’ll use dscl and dscacheutil, let’s create a new Host entry to map myvhost.loc to 127.0.0.1 (I like adding .loc to distinguish my added hosts, but you’re free to use anything else) :

sudo dscl localhost -create /Local/Default/Hosts/myvhost.loc IPAddress 127.0.0.1

Then to be sure it’s looked up correctly by software (in fact it’s only needed if you tried to access the myvhost.loc before adding it) :

sudo dscacheutil -flushcache

A little handy feature of the new dscacheutil when we’re at it :

sudo dscacheutil -cachedump -entries Host

This will list all entries cached by Leopard, it can comes in handy when trying to solve a name resolution problem.

And finally if you want to get ride of your entry later on :

sudo dscl localhost -delete /Local/Default/Hosts/myvhost.loc

[Update 2008/01/07]
Benjamin Stiglitz wrote a comment to say /etc/hosts is now automatically watched for changes on Leopard, so there’s no more need to play with dscl to add simple host. Thanks again Benjamin.

Published on Sat, 05 Jan 2008 18:36

Leopard Spaces Tips

Here’s a quick tips for those of you using Leopard Spaces functionnality. If you want to move a window from one “space” to another simply drag the window to the right/left/top or bottom edge of the screen (depending to which “space” you want to put it in) just like if wanted to put it out of the screen and wait a second.

Spaces should automaticaly switch to the next “space” and the window still be under your cursor. Drop it there or reiterate to move it to another “space”.

Published on Fri, 23 Nov 2007 09:44

(t)csh and dircolors problem

I encountered a little problem today, I use macports version of coreutils which gives me access to gnu versions of some commands (for full list : sudo port contents coreutils | grep /bin). My problem is related to one of those I’m using in my bashrc to color my shell : dircolors (gdircolors in macports).

This little commands allows you to generate LS_COLORS values (as the name seems to imply, it’s used by ls command) from a config file (~/.dir_colors in my case). I confidently modified this file today and was welcomed by a nice csh: Unknown colorls variable `su'.
It turns out there are an incompatibility between LS_COLORS generated by current version of dircolors in coreutils and (t)csh : tcsh treat LS_COLORS as a magic environment variable, which means it is parsed for its own use in ls builtin command.

The culprits in my .dir_colors file was :

#SETUID 37;41 # file that is setuid (u+s)
#SETGID 30;43 # file that is setgid (g+s)
#STICKY_OTHER_WRITABLE 30;42 # dir that is sticky and other-writable (+t,o+w)
#OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky
#STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable

As you can see a simple fix is to comment them out.

In fact I’m not sure why I see those errors poping up, as I’m using bash ans it’s now the default in MacOSX.

Published on Tue, 04 Sep 2007 15:10

FUSE and SSHFS for MacOS X

FUSE is a library initially developed for Linux then ported to FreeBSD and now on MacOS X, allowing implementation of a filesystem in a userspace program.

There are already numerous implementations going on from nfs to bittorent filesystem (see Filesystems on Fuse Wiki).

Yesterday, google employee Amit Singh announced the release of a MacFuse version including, amongst other things, a Virtual file system kernel extension and a patch to sshfs.

So, we now have all elements needed to use sshfs on MacOS X, YEAHH !!!
But wait… what can we do with sshfs ?

The big things about sshfs is it allows you to mount on your local machine a remote directory through ssh. On Mac it means you see the remote directory as an external mount point (on your desktop for example, just like an external hard drive).

Currently (at least on my configuration) the finder does not allow to copy file to the mounted filesystem as it does not recognize correctly the available free space, but it works beautifully with other apps (text editor, etc.) or in the console.

Installation is a little bit fastidious for now, but if you follow carefully the MacFuse installation How-To it should not be infeasible.

When installation is complete, just got to you console and type :

mkdir /Users/yourusername/Desktop/RemoteFS
sshfs remote_username@remotehost:/your/remote/directory /Users/yourusername/Desktop/RemoteFS

This mount the /your/remote/directory on your Desktop as RemoteFS.

To unmount it just use :

umount /Users/yourusername/Desktop/RemoteFS
Published on Fri, 12 Jan 2007 12:04

Installing PostGIS 1.2.0 with MacPorts PostgreSQL 8.1

In the previous post I detailed how to install PostgreSQL with MacPorts. This time we will see how to get the latest PostGIS (version 1.2.0 as of this writing) installed.

MacPorts provide PostGIS 1.1.1 but it depends on postgresql8 and we decided to go for the postgresql81 version last time. So we’ll have some handwork to get all run together.

First install proj and geos from MacPorts

sudo port install proj
sudo port install geos

then download, extract, compile and install PostGIS 1.2.0 :

curl -O http://postgis.refractions.net/download/postgis-1.2.0.tar.gz
tar xvzf postgis-1.2.0.tar.gz
cd postgis-1.2.0
./configure --libdir=/opt/local/lib/postgresql81/ --datadir=/opt/local/share/postgis --with-pgsql=/opt/local/lib/postgresql81/bin/pg_config --with-geos=/opt/local/bin/geos-config --with-prog=/opt/local/
make
sudo make install

Here we are, PostGIS 1.2.0 installed on a PostgreSQL 8.1.

Now every time you need to use PostGIS functions you need to configure your database (every new database need an “enabling phase”. You can use a template, but I will not cover this part) as follow :

createlang plpgsql yourdatabase
psql -f /opt/local/share/postgis/lwpostgis.sql -d your_database
psql -f /opt/local/share/postgis/spatial_ref_sys.sql -d your_database

[Update (04/01/2008) : Add missing /share/ in paths. thanks Galen]

If you already had an old version of PostGIS installed and want to upgrade your databases, follow the “UPGRADING EXISTING SPATIAL DATABASES” parts of PostGIS README.postgis.

Published on Wed, 20 Dec 2006 12:47

Multiple identities in one account with Apple Mail.app

Over the time I tend to accumulate mail adresses and accounts. Not so long ago, I decided to switch from a multiple mail accounts to a single imap account where I aggregated all others.

I used to be an Apple Mail.app user, but this switch caused me some troubles. How to specify different (legitimate) sender addresses with only one account configured ? I thought it was impossible and so decided to switch to Mozilla Thunderbird which allows you to set different sender addresses by account.

But recently, I found it was possible in Mail.app and here’s how :

In your account configuration, enter a comma-separated list of adresses in the “Email Address” field.

Multiple identities for one account

Then, you’ll be able to choose which sender address should be used when writing a new mail.

Choose which adresse to use when writing a new mail

For those of you interested in my configuration, I operate a simple linux box with Postfix, Courier-Imapd and Maildrop. Then I use Fetchmail to grab mails from my different accounts and put them in my imap setup.

[Update]
Drew leave a comment about a solution to have different names for each addresses. It require you edit the preferences plist file : Mac OS X Mail app config – EmailDiscussions.com

Published on Sun, 05 Nov 2006 09:30

RSS