1. Gmail CSV to mutt Aliases

    body

    I've recently been moving from the slow, bulky AJAX of the Gmail interface to the nice, lean, familiar keybinding of mutt.  Below is a simple ruby script I wrote to convert the Gmail CSV of your contacts to useful mutt aluases:

    #!/usr/bin/ruby
    require 'iconv'

    names = []

    Iconv.iconv('UTF32//IGNORE','UTF-8',File.open(ARGV[0]).read)[0].gsub(/\000/,").sub(/^../,").each("\n") do |line|
       f = line.chomp.split(/"?,"?/)
       f[1] = f[1].split('@')[0].sub('%','@') if f[1] =~ /%/
       f[0] = f[1] if f[0].to_s == ""
       next if f[0] == 'Name'
       puts "alias \"#{f[1]}\" \"#{f[0]}\" <#{f[1]}>"
       next unless names.index(f[0]).nil?
       puts "alias \"#{f[0].gsub(' ',")}\" \"#{f[0]}\" <#{f[1]}>"
       names << f[0]
    end

    Tags:
    Creative Commons Licence © 2006-2008 Stephen Paul Weber. Some Rights Reserved.

    Reply / Comment

    advanced comment form |

Stephen Paul Weber