{"id":456,"date":"2011-02-12T09:44:27","date_gmt":"2011-02-12T08:44:27","guid":{"rendered":"http:\/\/www.streppone.it\/cosimo\/blog\/2011\/02\/how-to-convert-opera-contacts-file-to-mutt-aliases-format\/"},"modified":"2011-02-12T09:44:27","modified_gmt":"2011-02-12T08:44:27","slug":"how-to-convert-opera-contacts-file-to-mutt-aliases-format","status":"publish","type":"post","link":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/02\/how-to-convert-opera-contacts-file-to-mutt-aliases-format\/","title":{"rendered":"How to convert Opera contacts file to Mutt aliases format"},"content":{"rendered":"<p>Recently I&#39;ve been looking more and more into <a href=\"http:\/\/www.mutt.org\/\" rel=\"nofollow\">mutt, the email client<\/a>. I&#39;ve been a very happy <a href=\"http:\/\/www.opera.com\/mail\/\" rel=\"nofollow\">M2<\/a> (Opera built-in email client) user for almost 3 years now. But still I felt I was missing something if I didn&#39;t try out mutt. I&#39;ve been a <b>pine<\/b> user as well, many many years ago :) So, decided to give it a go, I started about a month ago.<\/p>\n<p>I struggled a bit while getting a reasonable <code>.muttrc<\/code> file together. Fortunately, there&#39;s plenty of examples out there. After getting a working config, the problem was to get back my contacts list.<\/p>\n<p>Mutt has a simple address book integration (through <code>abook<\/code>) and stores the contacts into an <code>alias<\/code> file, typically <code>~\/.mutt\/aliases<\/code>. Now, Opera can of course export all your mail contacts to an <code>.adr<\/code> file, a simple &quot;addressbook&quot; text file. Did that, and I needed to convert it to mutt&#39;s aliases format.<\/p>\n<p>Ten minutes later, a Perl script to do just that was ready. Here it is:<\/p>\n<pre><code>\r\n#!\/usr\/bin\/env perl\r\n#\r\n# Convert Opera contacts file (.adr) into\r\n# mutt aliases file format.\r\n#\r\n# Usage:\r\n#   perl opera-adr-to-mutt-aliases.pl &lt; ~\/.opera\/contacts.adr &gt;&gt; ~\/.mutt\/aliases\r\n#\r\n# Cosimo, 31\/Jan\/2011\r\n#\r\n\r\nuse strict;\r\nuse warnings;\r\nuse utf8;\r\n\r\nsub harvest ($) {\r\n    my ($contact_info) = @_;\r\n\r\n    my ($id)    = $contact_info =~ m{^ s+ ID   = (.*) $}mx;\r\n    my ($name)  = $contact_info =~ m{^ s+ NAME = (.*) $}mx;\r\n    my ($email) = $contact_info =~ m{^ s+ MAIL = (.*) $}mx;\r\n\r\n    return if ! $id and ! $email;\r\n\r\n    return {\r\n        ID    =&gt; $id,\r\n        NAME  =&gt; $name,\r\n        MAIL =&gt; $email,\r\n    };\r\n\r\n}\r\n\r\nmy $adr_file_contents = q{};\r\n$adr_file_contents .= $_ while &lt;STDIN&gt;;\r\n\r\nmy @contacts = split m{#CONTACT}, $adr_file_contents;\r\n\r\nfor (@contacts) {\r\n    my $contact = harvest($_) or next;\r\n    my ($first_word) = $contact-&gt;{MAIL} =~ m{ (S+) @ }x;\r\n    printf &quot;alias %s %s &lt;%s&gt;n&quot;,\r\n        lc($first_word), $contact-&gt;{NAME}, $contact-&gt;{MAIL};\r\n}\r\n<\/code><\/pre>\n<p>Download link: <a href=\"https:\/\/gist.github.com\/803454\" rel=\"nofollow\">https:\/\/gist.github.com\/803454<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently I&#39;ve been looking more and more into mutt, the email client. I&#39;ve been a very happy M2 (Opera built-in email client) user for almost 3 years now. But still I felt I was missing something if I didn&#39;t try out mutt. I&#39;ve been a pine user as well, many many years ago :) So, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[338,335,336,63,337,339,340,74,50,334],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to convert Opera contacts file to Mutt aliases format - Random hacking<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/02\/how-to-convert-opera-contacts-file-to-mutt-aliases-format\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to convert Opera contacts file to Mutt aliases format - Random hacking\" \/>\n<meta property=\"og:description\" content=\"Recently I&#039;ve been looking more and more into mutt, the email client. I&#039;ve been a very happy M2 (Opera built-in email client) user for almost 3 years now. But still I felt I was missing something if I didn&#039;t try out mutt. I&#039;ve been a pine user as well, many many years ago :) So, [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/02\/how-to-convert-opera-contacts-file-to-mutt-aliases-format\/\" \/>\n<meta property=\"og:site_name\" content=\"Random hacking\" \/>\n<meta property=\"article:published_time\" content=\"2011-02-12T08:44:27+00:00\" \/>\n<meta name=\"author\" content=\"cosimo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"cosimo\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/02\/how-to-convert-opera-contacts-file-to-mutt-aliases-format\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/02\/how-to-convert-opera-contacts-file-to-mutt-aliases-format\/\"},\"author\":{\"name\":\"cosimo\",\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1\"},\"headline\":\"How to convert Opera contacts file to Mutt aliases format\",\"datePublished\":\"2011-02-12T08:44:27+00:00\",\"dateModified\":\"2011-02-12T08:44:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/02\/how-to-convert-opera-contacts-file-to-mutt-aliases-format\/\"},\"wordCount\":181,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1\"},\"keywords\":[\"aliases\",\"contacts\",\"converter\",\"github\",\"m2\",\"mail\",\"mutt\",\"opera\",\"perl\",\"pine\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/02\/how-to-convert-opera-contacts-file-to-mutt-aliases-format\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/02\/how-to-convert-opera-contacts-file-to-mutt-aliases-format\/\",\"url\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/02\/how-to-convert-opera-contacts-file-to-mutt-aliases-format\/\",\"name\":\"How to convert Opera contacts file to Mutt aliases format - Random hacking\",\"isPartOf\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#website\"},\"datePublished\":\"2011-02-12T08:44:27+00:00\",\"dateModified\":\"2011-02-12T08:44:27+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/02\/how-to-convert-opera-contacts-file-to-mutt-aliases-format\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/02\/how-to-convert-opera-contacts-file-to-mutt-aliases-format\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/02\/how-to-convert-opera-contacts-file-to-mutt-aliases-format\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.streppone.it\/cosimo\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to convert Opera contacts file to Mutt aliases format\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#website\",\"url\":\"https:\/\/www.streppone.it\/cosimo\/blog\/\",\"name\":\"Random hacking\",\"description\":\"Assume nothing. Code defensively. Keep it simple, stupid!\",\"publisher\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.streppone.it\/cosimo\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1\",\"name\":\"cosimo\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cb1d938720df45a2720724aae99e3bfc?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cb1d938720df45a2720724aae99e3bfc?s=96&r=g\",\"caption\":\"cosimo\"},\"logo\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/image\/\"},\"url\":\"https:\/\/www.streppone.it\/cosimo\/blog\/author\/cosimo\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to convert Opera contacts file to Mutt aliases format - Random hacking","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/02\/how-to-convert-opera-contacts-file-to-mutt-aliases-format\/","og_locale":"en_US","og_type":"article","og_title":"How to convert Opera contacts file to Mutt aliases format - Random hacking","og_description":"Recently I&#39;ve been looking more and more into mutt, the email client. I&#39;ve been a very happy M2 (Opera built-in email client) user for almost 3 years now. But still I felt I was missing something if I didn&#39;t try out mutt. I&#39;ve been a pine user as well, many many years ago :) So, [&hellip;]","og_url":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/02\/how-to-convert-opera-contacts-file-to-mutt-aliases-format\/","og_site_name":"Random hacking","article_published_time":"2011-02-12T08:44:27+00:00","author":"cosimo","twitter_card":"summary_large_image","twitter_misc":{"Written by":"cosimo","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/02\/how-to-convert-opera-contacts-file-to-mutt-aliases-format\/#article","isPartOf":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/02\/how-to-convert-opera-contacts-file-to-mutt-aliases-format\/"},"author":{"name":"cosimo","@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1"},"headline":"How to convert Opera contacts file to Mutt aliases format","datePublished":"2011-02-12T08:44:27+00:00","dateModified":"2011-02-12T08:44:27+00:00","mainEntityOfPage":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/02\/how-to-convert-opera-contacts-file-to-mutt-aliases-format\/"},"wordCount":181,"commentCount":0,"publisher":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1"},"keywords":["aliases","contacts","converter","github","m2","mail","mutt","opera","perl","pine"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.streppone.it\/cosimo\/blog\/2011\/02\/how-to-convert-opera-contacts-file-to-mutt-aliases-format\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/02\/how-to-convert-opera-contacts-file-to-mutt-aliases-format\/","url":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/02\/how-to-convert-opera-contacts-file-to-mutt-aliases-format\/","name":"How to convert Opera contacts file to Mutt aliases format - Random hacking","isPartOf":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#website"},"datePublished":"2011-02-12T08:44:27+00:00","dateModified":"2011-02-12T08:44:27+00:00","breadcrumb":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/02\/how-to-convert-opera-contacts-file-to-mutt-aliases-format\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.streppone.it\/cosimo\/blog\/2011\/02\/how-to-convert-opera-contacts-file-to-mutt-aliases-format\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/02\/how-to-convert-opera-contacts-file-to-mutt-aliases-format\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.streppone.it\/cosimo\/blog\/"},{"@type":"ListItem","position":2,"name":"How to convert Opera contacts file to Mutt aliases format"}]},{"@type":"WebSite","@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#website","url":"https:\/\/www.streppone.it\/cosimo\/blog\/","name":"Random hacking","description":"Assume nothing. Code defensively. Keep it simple, stupid!","publisher":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.streppone.it\/cosimo\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1","name":"cosimo","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/cb1d938720df45a2720724aae99e3bfc?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cb1d938720df45a2720724aae99e3bfc?s=96&r=g","caption":"cosimo"},"logo":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/image\/"},"url":"https:\/\/www.streppone.it\/cosimo\/blog\/author\/cosimo\/"}]}},"_links":{"self":[{"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/posts\/456"}],"collection":[{"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/comments?post=456"}],"version-history":[{"count":0,"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/posts\/456\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/media?parent=456"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/categories?post=456"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/tags?post=456"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}