<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.7.2">Jekyll</generator><link href="http://fiandes.io/feed.xml" rel="self" type="application/atom+xml" /><link href="http://fiandes.io/" rel="alternate" type="text/html" /><updated>2018-02-11T21:15:11+00:00</updated><id>http://fiandes.io/</id><title type="html">&amp;gt; fiandes.io</title><subtitle>The blog of Luciano Fiandesio</subtitle><author><name>Luciano Fiandesio</name><email>luciano@fiandes.io</email></author><entry><title type="html">Notes on self-hosting essential apps</title><link href="http://fiandes.io/notes-on-self-hosting-essential-apps/" rel="alternate" type="text/html" title="Notes on self-hosting essential apps" /><published>2016-09-14T00:00:00+00:00</published><updated>2016-09-14T00:00:00+00:00</updated><id>http://fiandes.io/notes-on-self-hosting-essential-apps</id><content type="html" xml:base="http://fiandes.io/notes-on-self-hosting-essential-apps/">&lt;p&gt;These notes contain a relatively simple guide to set-up a fresh Ubuntu server and self-host a number of (&lt;em&gt;what I consider&lt;/em&gt;) essential apps.&lt;/p&gt;

&lt;p&gt;There are plenty of reasons you want to self-host applications (privacy, who owns your data, your data being stolen, etc.). On the other hand, self-hosting forces you to be very proactive about your data, chiefly:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;establish a rock-solid backup policy&lt;/li&gt;
  &lt;li&gt;keep your server secure&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both back-up and security are not easy feat to get right, so self-hosting requires a certain degree of discipline. Having said that, with a relatively small time-investment, I have never suffered any major (or minor) data-loss or data breach.&lt;/p&gt;

&lt;p&gt;I started to look for a self-hosted alternative to Dropbox back in 2013, mostly out of privacy concerns, and I continued to add more self-hosted applications to my server (&lt;del&gt;a 4GB RAM box hosted with &lt;a href=&quot;https://www.hetzner.de/en/&quot;&gt;Hetzner&lt;/a&gt;&lt;/del&gt;). At this point (end of 2016), my digital backbone is almost completely self-hosted, except for an e-mail server, which I happily leave to &lt;a href=&quot;https://www.fastmail.com/&quot;&gt;Fastmail&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The configuration process described here is based on Ubuntu 16.04 LTS and does install and configure the following applications:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.resilio.com/individuals/&quot;&gt;Resilio Sync&lt;/a&gt; (formerly known as BitTorrent Sync)&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://sabre.io/baikal/&quot;&gt;Baïkal&lt;/a&gt; Baïkal (Cal and CardDAV server)&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://tt-rss.org/&quot;&gt;Tiny Tiny RSS&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.dokuwiki.org/dokuwiki#&quot;&gt;DokuWiki&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://piwigo.org/&quot;&gt;Piwigo&lt;/a&gt; (photo gallery)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All the web-facing applications use HTTPS (thanks &lt;a href=&quot;https://letsencrypt.org/&quot;&gt;Let’s Encrypt!&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;It is assumed that the server IP address is associated to a DNS entry and that all the applications have a sub domain, like so:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;- btsync.mydomain.com
- dav.mydomain.com
- wiki.mydomain.com
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;… and so on.&lt;/p&gt;

&lt;p&gt;There is an incredible number of self-hosted applications which can be used to replace closed-source, paid applications. A good starting point is &lt;a href=&quot;https://github.com/Kickball/awesome-selfhosted&quot;&gt;this&lt;/a&gt; ‘awesome’ list and &lt;a href=&quot;https://www.reddit.com/r/selfhosted/&quot;&gt;this&lt;/a&gt; sub-reddit.&lt;/p&gt;

&lt;h2 id=&quot;os&quot;&gt;OS&lt;/h2&gt;

&lt;p&gt;I assume that Ubuntu 16.04 LTS is installed on a new server and the logged in user is &lt;code class=&quot;highlighter-rouge&quot;&gt;root&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The very first commands to run will update the package repositories and the system.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;apt update &amp;amp;&amp;amp; sudo apt upgrade
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Change the root password:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;passw
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Setup a login user, with sudo permission&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;adduser youruser
gpasswd -a youruser sudo
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;hardening&quot;&gt;Hardening&lt;/h2&gt;

&lt;p&gt;I don’t want to be hacked, rooted or my server to turn into a remotely controlled zombie. Harden.Your.Server.
I have been using this excellent &lt;a href=&quot;https://www.thefanclub.co.za/how-to/how-secure-ubuntu-1604-lts-server-part-1-basics&quot;&gt;collection&lt;/a&gt; of security recomendations to harden my box, and you should do the same.&lt;/p&gt;

&lt;p&gt;The crucial bits are documented here. I &lt;strong&gt;warmly&lt;/strong&gt; recommend to read the above guide and decide for yourself how paranoid you want to be when hardening your server.&lt;/p&gt;

&lt;h3 id=&quot;firewall&quot;&gt;Firewall&lt;/h3&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# install UFW (Uncomplicated Firewall)
sudo apt-get install ufw

# allow ssh and apache 80/443
sudo ufw allow ssh
sudo ufw allow &quot;Apache Full&quot;

# enable the firewall
sudo ufw enable
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;harden-ssh&quot;&gt;Harden SSH&lt;/h3&gt;

&lt;p&gt;Just follow this &lt;a href=&quot;https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-16-04&quot;&gt;setup&lt;/a&gt;.
It shows how to set up public key authentication for the new user and disable password authentication.&lt;/p&gt;

&lt;p&gt;Be extra careful when editing the server’s SSL configuration. It is scary simple to get locked out of a server.&lt;/p&gt;

&lt;h3 id=&quot;secure-shared-memory&quot;&gt;Secure shared memory&lt;/h3&gt;

&lt;p&gt;Shared memory can be used in an attack against a running service, apache2 or httpd for example. More info &lt;a href=&quot;https://help.ubuntu.com/community/StricterDefaults&quot;&gt;here&lt;/a&gt;.
To secure the shared memory:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo vim /etc/fstab
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Add the following line:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;tmpfs     /run/shm     tmpfs     defaults,noexec,nosuid     0     0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Save and reboot.&lt;/p&gt;

&lt;h3 id=&quot;disable-ssl-v3&quot;&gt;Disable SSL v3&lt;/h3&gt;

&lt;p&gt;Here’s &lt;a href=&quot;http://disablessl3.com/&quot;&gt;why&lt;/a&gt; you want to disable SSL v3.&lt;/p&gt;

&lt;p&gt;TLTR; it’s broken and vulnerable.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo vim /etc/apache2/mods-available/ssl.conf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Change the line:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;SSLProtocol all -SSLv3
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;SSLProtocol all -SSLv2 -SSLv3
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Restart apache:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apache2ctl configtest &amp;amp;&amp;amp; sudo service apache2 restart 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;setup-fail2ban&quot;&gt;Setup fail2ban&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;http://www.fail2ban.org/wiki/index.php/Main_Page&quot;&gt;Fail2ban&lt;/a&gt; temporarily rejects IP addresses that are trying to do something dodgy with your server.
A classical example is a client try to brute force the SSH password. 
The default Fail2ban configuration only protectes SSH, but it’s (relatively) easy to configure it to add more checks (eg. apache HTTP server)&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install fail2ban -y
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;installing-applications&quot;&gt;Installing applications&lt;/h2&gt;

&lt;h3 id=&quot;lamp-stack&quot;&gt;LAMP Stack&lt;/h3&gt;

&lt;p&gt;Before installing any application, we want to install Apache2, MySQL and PHP.&lt;/p&gt;

&lt;p&gt;You can get away with a one liner:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install apache2 mysql-server php libapache2-mod-php php-mcrypt php-mysql
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;But you really want to follow this thorough &lt;a href=&quot;https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-16-04&quot;&gt;guide&lt;/a&gt;, from the guys @&lt;a href=&quot;https://www.digitalocean.com/&quot;&gt;DigitalOcean&lt;/a&gt; .&lt;/p&gt;

&lt;h3 id=&quot;resilio-sync&quot;&gt;Resilio Sync&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;https://www.resilio.com/individuals/&quot;&gt;Resilio Sync&lt;/a&gt; is the new incarnation of (the formerly known) BitTorrent Sync. In June, BitTorrent inc. &lt;a href=&quot;http://variety.com/2016/digital/news/bittorrent-sync-spinoff-resilio-1201787793/&quot;&gt;announced&lt;/a&gt; that the Sync product was going to be moved into a new company, called Resilio.
This news made me a bit nervous, but so far it seems that the new company is delivering. They recently released version 2.4 of the Sync client.&lt;/p&gt;

&lt;p&gt;Resilio Sync is essentially a Dropbox replacement: you should be aware that it is a closed-source software. There are open-source alternatives, such as &lt;a href=&quot;https://syncthing.net/&quot;&gt;SyncThing&lt;/a&gt; or &lt;a href=&quot;https://www.seafile.com/en/home/&quot;&gt;Seafile&lt;/a&gt;. I consider BitTorrent Sync (now Resilio Sync) the easiest to setup and to run and the more reliable.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/self-hosted-apps/resilio_large.png&quot; alt=&quot;Silvrback blog image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Before installing the Sync client, create the folder where the synchronized files will be stored.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# change your-user with the directory name of the user created before
sudo apt-get install acl 
mkdir /home/your-user/btsync_share/

sudo setfacl -R -m &quot;u:rslsync:rwx&quot; /home/your-user/btsync_share/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To install Resilio Sync, start by creating a new &lt;code class=&quot;highlighter-rouge&quot;&gt;apt&lt;/code&gt; source file&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;echo 'deb http://linux-packages.getsync.com/resilio-sync/deb resilio-sync non-free' | sudo tee --append /etc/apt/sources.list.d/resilio-sync.list
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Add public key with the following command:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;wget -qO - https://linux-packages.getsync.com/resilio-sync/key.asc | sudo apt-key add -
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Install&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get update &amp;amp;&amp;amp; sudo apt-get install resilio-sync
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Start Resilio Sync&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo service resilio-sync start
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The Linux version of Resilio Sync has a web-based UI available at 127.0.0.1:8888. The web UI is not accessible from the Internet, so we need to set up a reverse proxy.&lt;/p&gt;

&lt;p&gt;First enable the Apache modules required for the reverse proxy to work:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod rewrite
sudo a2enmod deflate
sudo a2enmod headers
sudo a2enmod proxy_balancer
sudo a2enmod proxy_connect
sudo a2enmod proxy_html
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Create the Apache configuration for the Resilio Sync UI.
Here, I assume that you have a domain name associated to your server and that each application will correspond to a sub-domain&lt;/p&gt;

&lt;p&gt;Let’s pretend that the domain name is &lt;code class=&quot;highlighter-rouge&quot;&gt;awesomehosted.com&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Create a new Apache configuration file&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo touch /etc/apache2/sites-available/btsync.awesomehosted.com.conf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Copy the following text to the new file&lt;/p&gt;

&lt;noscript&gt;&lt;pre&gt;400: Invalid request
&lt;/pre&gt;&lt;/noscript&gt;
&lt;script src=&quot;https://gist.github.com/38eac0183e1914d18015f36267d1fc2c.js?file=btsync.awesomehosted.com.conf&quot;&gt; &lt;/script&gt;

&lt;p&gt;Enable the configuration and restart Apache&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo a2ensite btsync.awesomehosted.com.conf
sudo service apache2 restart
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If the sub domains are already configured and propagated, you should be able to access the Resilio Sync console&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;http://btsync.awesomehosted.com
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;In case you haven’t configured the A records yet, just add an entry to the &lt;code class=&quot;highlighter-rouge&quot;&gt;/etc/hosts&lt;/code&gt; of the computer testing the connection&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[server ip] btsync.awesomehosted.com
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;baïkal&quot;&gt;Baïkal&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;http://sabre.io/baikal/&quot;&gt;Baïkal&lt;/a&gt; is an excellent CalDav and CardDav server. I have been using it for a couple of years, and it totally replaced any other cloud service for syncing contacts and calendar (Apple Cloud, etc.).
It is very stable and (kind of) easy to setup. The data are stored on SQLite, but for large dataset it is reccommended to use MySQL. I use SQLite because it’s easy to back up :)&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/self-hosted-apps/baikal_large.jpg&quot; alt=&quot;Silvrback blog image&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# install the dependencies
sudo apt-get install php7.0-sqlite3 php-xml php7.0-mbstring unzip

# fetch baikal
cd /var/www
sudo wget https://github.com/fruux/Baikal/releases/download/0.4.6/baikal-0.4.6.zip
sudo unzip baikal-0.4.6.zip 

# rename the baikal folder 
sudo mv baikal dav.awesomehosted.com
sudo rm baikal-0.4.6.zip

# fix permissions
sudo chown -R www-data:www-data dav.awesomehosted.com
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Create a new Apache configuration file&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo touch /etc/apache2/sites-available/dav.awesomehosted.com.conf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Copy the following text to the new file&lt;/p&gt;

&lt;noscript&gt;&lt;pre&gt;400: Invalid request
&lt;/pre&gt;&lt;/noscript&gt;
&lt;script src=&quot;https://gist.github.com/a4e189f18ddc8d8e450a8893fcd06c0f.js?file=dav.awesomehosted.com.conf&quot;&gt; &lt;/script&gt;

&lt;p&gt;And enable the configuration&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo a2ensite dav.awesomehosted.com.conf
sudo service apache2 restart
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Hit &lt;code class=&quot;highlighter-rouge&quot;&gt;dav.awesomehosted.com&lt;/code&gt; on your browser and you should access the configuration page. 
Choose an admin password and pick MySQL or SQLite. If you choose MySQL, you’ll have to create a database first.
I don’t bother creating a MySQL db for Baikal. I have around 1000 contacts and a relatively low number of entries in my calendars and never had a problem. Bonus: SQLite is easier to backup!&lt;/p&gt;

&lt;p&gt;As an Android user, I use &lt;a href=&quot;https://play.google.com/store/apps/details?id=org.dmfs.carddav.Sync&amp;amp;hl=en&quot;&gt;CardDAV-Sync&lt;/a&gt; to syncronize my contacts and &lt;a href=&quot;https://play.google.com/store/apps/details?id=org.dmfs.caldav.lib&amp;amp;hl=en&quot;&gt;CalDav-Sync&lt;/a&gt; for the calendar syncronization.&lt;/p&gt;

&lt;p&gt;Once you have created a new user (eg. johndoe), the url for the contacts is: &lt;code class=&quot;highlighter-rouge&quot;&gt;http://dav.awesomehosted.com/card.php/addressbooks/johndoe/default/&lt;/code&gt;.
The url for the calendar is: &lt;code class=&quot;highlighter-rouge&quot;&gt;http://dav.awesomehosted.com/cal.php/calendars/johndoe/default/&lt;/code&gt;.&lt;/p&gt;

&lt;h3 id=&quot;tiny-tiny-rss&quot;&gt;Tiny Tiny RSS&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;https://tt-rss.org/&quot;&gt;Tiny Tiny RSS&lt;/a&gt; (tt-rss for brevity) is a marvellous feed reader, which I use daily. There are &lt;a href=&quot;https://github.com/Kickball/awesome-selfhosted#feed-readers&quot;&gt;lots of self-hosted&lt;/a&gt; feed readers out there: I have tried few of them, and I settled with tt-rss. The set-up process is similar to the one used for the other applications.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/self-hosted-apps/tiny-tiny-rss_large.png&quot; alt=&quot;Silvrback blog image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Install some required PHP dependencies.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install php-curl php7.0-mbstring php-xml
sudo service apache2 restart
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Clone tt-rss&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cd /var/www

sudo git clone https://tt-rss.org/git/tt-rss.git tt-rss

sudo mv tt-rss rss.awesomehosted.com

sudo chown -R www-data:www-data rss.awesomehosted.com

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Create a new Apache configuration file&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo touch /etc/apache2/sites-available/rss.awesomehosted.com.conf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Copy the following text to the new file&lt;/p&gt;

&lt;noscript&gt;&lt;pre&gt;400: Invalid request
&lt;/pre&gt;&lt;/noscript&gt;
&lt;script src=&quot;https://gist.github.com/e4e14a0234f71cbe4ecbcffa31cdc595.js?file=rss.awesomehosted.com.conf&quot;&gt; &lt;/script&gt;

&lt;p&gt;And enable the configuration&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo a2ensite rss.awesomehosted.com.conf
sudo service apache2 restart
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Create the Tiny Tiny RSS database. Don’t forget to keep the password in a safe place.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mysql -u root -p

mysql&amp;gt; create database ttRssDB;
mysql&amp;gt; grant all on ttRssDB.* to ttRss@localhost identified by 'password';
mysql&amp;gt; flush privileges;
mysql&amp;gt; \q
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The first time you hit the url ‘http://rss.awesomehosted.com’, a set-up page is displayed. Admittedly, the setup process of tt-rss it’s a bit quirky.
Fill the configuration form with the information provided during the db creation stage.
Click on the “Test Configuration” button to double-check you can access the database and all required libraries are present. Finally, select “Initialize Database”. Now you should be presented with a textbox containing the php configuration code required to run tt-rss. Press the “Install Configution” button. This will create a &lt;code class=&quot;highlighter-rouge&quot;&gt;config.php&lt;/code&gt; file in the root of the main application directory.&lt;/p&gt;

&lt;p&gt;You should now be able to access tt-rss. The default username and password is: &lt;code class=&quot;highlighter-rouge&quot;&gt;admin/password&lt;/code&gt;. Don’t forget to create a new user and change the administrative password!&lt;/p&gt;

&lt;p&gt;The last step required for a fully functional feed reader is creating a cronjob to refresh the feeds at a specified interval.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;crontab -e

*/30 * * * \* /usr/bin/php /var/www/tt-rss/update.php --feeds --quiet
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;docuwiki&quot;&gt;Docuwiki&lt;/h3&gt;

&lt;p&gt;My wiki is probably the most important part of my digital life. I keep track of books I read or I want to read, movies, a ’90s style weblog, ideas and notes. Before starting a personal wiki, I was an heavy user of Evernote. The problem with a note-style knowledge management system, such has Evernote, is that it quickly becomes a huge knowledge sink and the truly important bits of information that I want to retain were lost in the noise of the less important data.&lt;/p&gt;

&lt;p&gt;A wiki instead forces me to curate the information that I want to preserve. A wiki is akin to having a paper notebook. It is slower, but it forces me to think about the actual bit of data that I’m working on.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/self-hosted-apps/dokuwiki_large.png&quot; alt=&quot;Silvrback blog image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.dokuwiki.org/dokuwiki#&quot;&gt;Docuwiki&lt;/a&gt; is a very simple wiki platform with a couple of advantages over other wikis: it has a large plugin ecosystem and it is file-based, so super-easy to back-up. No database, less attack-surface. The installation is also straightforward.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cd ~

# download the latest version of docuwiki
wget http://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz
tar xvf dokuwiki-stable.tgz
sudo mv dokuwiki-2016-06-26a/ /var/www/wiki

# setup folder permissions
sudo chown www-data:www-data -R /var/www/wiki/

# create apache conf file
touch /etc/apache2/sites-available/wiki.awesomehosted.com.conf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Copy the following configuration snippet to the new file&lt;/p&gt;

&lt;noscript&gt;&lt;pre&gt;400: Invalid request
&lt;/pre&gt;&lt;/noscript&gt;
&lt;script src=&quot;https://gist.github.com/d9ce4a2c15484f347c623f0c7527d71b.js?file=wiki.awesomehosted.com.conf&quot;&gt; &lt;/script&gt;

&lt;p&gt;Restart Apache and test the installation by browsing to &lt;code class=&quot;highlighter-rouge&quot;&gt;http://wiki.awesomehosted.com&lt;/code&gt;.&lt;/p&gt;

&lt;h3 id=&quot;piwigo&quot;&gt;Piwigo&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;http://piwigo.org/&quot;&gt;Piwigo&lt;/a&gt; is a photo gallery web-application. I use it to share photo galleries with my family. I switched from the very stylish-looking &lt;a href=&quot;https://lychee.electerious.com/&quot;&gt;Lychee&lt;/a&gt; to Piwigo because Lychee doesn’t support custom ordering of photos in a gallery.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/self-hosted-apps/piwigo_large.jpg&quot; alt=&quot;Silvrback blog image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Piwigo setup is straightforward. Start by creating a database. Don’t forget to change the password.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mysql -u root -p

CREATE DATABASE piwigo;

CREATE USER piwigouser@localhost IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON piwigo.* TO piwigouser@localhost;

FLUSH PRIVILEGES;

exit
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cd ~

sudo apt-get install unzip php-gd

wget &quot;http://piwigo.org/download/dlcounter.php?code=latest&quot; -O piwigo-gallery.zip

sudo unzip piwigo-gallery.zip -d /var/www

sudo mv /var/www/piwigo /var/www/gallery.awesomehosted.nl

sudo chown www-data: -R /var/www/gallery.cryptonomicon.nl/

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Create the Apache config file&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo touch /etc/apache2/sites-available/gallery.awesomehosted.com.conf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Copy the following configuration to &lt;code class=&quot;highlighter-rouge&quot;&gt;gallery.awesomehosted.com.conf&lt;/code&gt;&lt;/p&gt;

&lt;noscript&gt;&lt;pre&gt;400: Invalid request
&lt;/pre&gt;&lt;/noscript&gt;
&lt;script src=&quot;https://gist.github.com/451c7d1ab3d3257a838560f0ed90b222.js?file=gallery.awesomehosted.com.conf&quot;&gt; &lt;/script&gt;

&lt;p&gt;Finally, add the following lines to &lt;code class=&quot;highlighter-rouge&quot;&gt;my.cnf&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo vim /etc/mysql/my.cnf

[mysqld]
sql-mode=&quot;&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This is required to avoid a &lt;a href=&quot;https://github.com/Piwigo/Piwigo/issues/376&quot;&gt;weird error&lt;/a&gt; when changing the order of the photos in the gallery.&lt;/p&gt;

&lt;h2 id=&quot;secure-the-applications-with-tlsssl&quot;&gt;Secure the applications with TLS/SSL&lt;/h2&gt;

&lt;p&gt;Once all the applications are installed, configured and running on port 80 within Apache 2, it’s time to install a TLS/SSL certificate in order to encrypt the traffic between client and server. The obvious choice these days is to use &lt;a href=&quot;https://letsencrypt.org/&quot;&gt;Let’s Encrypt&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s Encrypt is a new SSL authority that provides free SSL certificates and a super-simple command line tool to streamline the creation and renewal of certificates.&lt;/p&gt;

&lt;p&gt;Let’s start by installing the command line tool.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install python-letsencrypt-apache
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Modify the Apache 2 default virtual host file, &lt;code class=&quot;highlighter-rouge&quot;&gt;000-default.conf&lt;/code&gt; so that the domain name of your server is properly defined.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo vim /etc/apache2/sites-available/000-default.conf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Make sure that the &lt;code class=&quot;highlighter-rouge&quot;&gt;ServerName&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;ServerAlias&lt;/code&gt; are pointing to the correct domain name - let’s continue using the fictional &lt;code class=&quot;highlighter-rouge&quot;&gt;awesomehosted.com&lt;/code&gt; domain name:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ServerName awesomehosted.com
ServerAlias www.awesomehosted.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/awesomehosted
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I like to configure the root directory with my own index.html, hence &lt;code class=&quot;highlighter-rouge&quot;&gt;DocumentRoot&lt;/code&gt; pointing to a non default folder.&lt;/p&gt;

&lt;p&gt;Finally, execute the command that will magically install and configure the SSL certificate for the main domain and the subdomains.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;letsencrypt --apache -d awesomehosted.com -d www.awesomehosted.com -d btsync.awesomehosted.com -d dav.awesomehosted.com -d rss.awesomehosted.com -d wiki.awesomehosted.com -d gallery.awesomehosted.com
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Note that his command will &lt;strong&gt;fail&lt;/strong&gt; if the DNS settings for the domains and subdomains are not properly configured and propagated.&lt;/p&gt;

&lt;p&gt;Stay tuned for the second part of these notes, concerning my backup strategy.&lt;/p&gt;</content><author><name>Luciano Fiandesio</name><email>luciano@fiandes.io</email></author><category term="filesharing" /><category term="wiki" /><category term="dav" /><summary type="html">These notes contain a relatively simple guide to set-up a fresh Ubuntu server and self-host a number of (what I consider) essential apps.</summary></entry><entry><title type="html">Mutt 1.7.0 on El Capitan</title><link href="http://fiandes.io/mutt-1-7-0-on-el-capitan/" rel="alternate" type="text/html" title="Mutt 1.7.0 on El Capitan" /><published>2016-08-21T00:00:00+00:00</published><updated>2016-08-21T00:00:00+00:00</updated><id>http://fiandes.io/mutt-1-7-0-on-el-capitan</id><content type="html" xml:base="http://fiandes.io/mutt-1-7-0-on-el-capitan/">&lt;p&gt;This is an update to my &lt;a href=&quot;http://www.lucianofiandesio.com/getting-started-with-mutt-on-osx&quot;&gt;one year old post&lt;/a&gt; about mutt and OS X.
On August 2016, a &lt;a href=&quot;https://marc.info/?l=mutt-users&amp;amp;m=147154326009383&quot;&gt;new version&lt;/a&gt; of mutt was released. This version includes the sidebar patch and the trash folder patch, so no need to mess around with patches any longer.
Here are my notes to get started with the new version.&lt;/p&gt;

&lt;p&gt;If you have previously installed mutt via Homebrew, remove it.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;brew uninstall mutt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Download mutt and untar the archive.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;wget ftp://ftp.mutt.org/pub/mutt/mutt-1.7.0.tar.gz
tar xopf mutt-1.7.0.tar.gz
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Configure and build.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;export CPPFLAGS=-I/usr/local/opt/openssl/include
./configure --enable-imap --enable-smtp --enable-sidebar --enable-gpgme --with-regex  --enable-locales-fix --with-ssl --with-sasl --with-gss --enable-hcache --with-tokyocabinet

make

make install
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I had to link to my (brew based) openssl installation folder for the &lt;code class=&quot;highlighter-rouge&quot;&gt;--with-ssl&lt;/code&gt; flag to work. You also need to install Tokyo Cabinet for the header cache flag to work (&lt;code class=&quot;highlighter-rouge&quot;&gt;brew install tokyo-cabinet&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;That should be it. 
Do not forget to set the &lt;code class=&quot;highlighter-rouge&quot;&gt;trash&lt;/code&gt; option in your .muttrc file. &lt;a href=&quot;https://github.com/luciano-fiandesio/dotfiles/blob/master/.muttrc#L35&quot;&gt;Mine&lt;/a&gt; is configured like so:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;set trash=imaps://$my_server/INBOX.Trash
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;For additional information on how to configure mutt on OS X, take a look at my &lt;a href=&quot;http://www.lucianofiandesio.com/getting-started-with-mutt-on-osx&quot;&gt;previous&lt;/a&gt; post.&lt;/p&gt;</content><author><name>Luciano Fiandesio</name><email>luciano@fiandes.io</email></author><category term="mutt" /><category term="email" /><category term="gpg" /><summary type="html">This is an update to my one year old post about mutt and OS X. On August 2016, a new version of mutt was released. This version includes the sidebar patch and the trash folder patch, so no need to mess around with patches any longer. Here are my notes to get started with the new version.</summary></entry><entry><title type="html">Getting started with Mutt on OSX</title><link href="http://fiandes.io/getting-started-with-mutt-on-osx/" rel="alternate" type="text/html" title="Getting started with Mutt on OSX" /><published>2015-05-29T00:00:00+00:00</published><updated>2015-05-29T00:00:00+00:00</updated><id>http://fiandes.io/getting-started-with-mutt-on-osx</id><content type="html" xml:base="http://fiandes.io/getting-started-with-mutt-on-osx/">&lt;p&gt;&lt;em&gt;20/08/2016&lt;/em&gt;
I wrote a &lt;a href=&quot;http://www.lucianofiandesio.com/mutt-1-7-0-on-el-capitan&quot;&gt;short upgrade&lt;/a&gt; to this guide, that uses the newly released mutt 1.7.0.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;Here are some notes on how to get started with &lt;a href=&quot;http://www.mutt.org/&quot;&gt;mutt&lt;/a&gt;  and &lt;a href=&quot;https://www.fastmail.com&quot;&gt;Fastmail&lt;/a&gt;  on OSX (Yosemite).
Most of this stuff applies to Linux as well. You can actually skip this whole mutt-is-awesome rant and checkout the “mutt” section of my &lt;a href=&quot;https://github.com/luciano-fiandesio/dotfiles&quot;&gt;doftiles&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;why-mutt&quot;&gt;Why mutt&lt;/h2&gt;

&lt;p&gt;mutt is stable, solid, predictable and flexible mail client. Also, I like writing in Vim. And I spend a lot of time in the command line.
In the past, mutt was a pain to setup. Just google for “mutt setup” and you will find some monster articles, like this &lt;a href=&quot;stevelosh.com/blog/2012/10/the-homely-mutt/&quot;&gt;one&lt;/a&gt; or this &lt;a href=&quot;http://linsec.ca/Using_mutt_on_OS_X&quot;&gt;one&lt;/a&gt;. Scary shit, uh?&lt;/p&gt;

&lt;p&gt;A “normal” setup would include mutt, &lt;a href=&quot;http://offlineimap.org/&quot;&gt;offlineimap&lt;/a&gt;, some smtp client, like &lt;a href=&quot;http://msmtp.sourceforge.net/&quot;&gt;msmtp&lt;/a&gt; and &lt;a href=&quot;http://notmuchmail.org/&quot;&gt;notmuch&lt;/a&gt; for searching your emails. Enough to scare away even the most determined hacker.&lt;/p&gt;

&lt;p&gt;My setup is way simpler, since mutt is able to send emails without a third-party smtp client (I don’t know exactly when that option has been introduced in mutt). Additionally, I don’t require to store my emails locally, I don’t need to reply when off-line and I can search using the excellent Fastmail web interface.&lt;/p&gt;

&lt;p&gt;This is how mutt looks like:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/mutt/mutt-blog-1.gif&quot; alt=&quot;mutt&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;get-mutt&quot;&gt;Get mutt&lt;/h2&gt;

&lt;p&gt;Vanilla mutt lacks some of the essential stuff, which is only available through patches. One is the trash patch - as in, send message to trash - and a sidebar to show IMAP folders. Applying a patch is not complicated - get the source, get the patch, &lt;code class=&quot;highlighter-rouge&quot;&gt;make&lt;/code&gt;.
In OSX, I can simply use Homebrew and get it done with a simple command.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;brew install kevwil/patches/mutt \
    --with-gpgme --with-trash-patch \
    --with-sidebar-patch --with-confirm-attachment-patch
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;talking-to-fastmail&quot;&gt;Talking to fastmail&lt;/h2&gt;

&lt;p&gt;mutt is configured through a .muttrc file. It’s a good idea to keep your configuration well organized and commented, because it can get a messy.&lt;/p&gt;

&lt;p&gt;This is the &lt;strong&gt;very&lt;/strong&gt; basic configuration required to fetch and send email through Fastmail.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;set my_server       =   mail.messagingengine.com
set my_smtp_server  =   mail.messagingengine.com
set my_user         =   xxx@fastmail.fm
set my_pass         =   &quot;`security find-internet-password -g -a lfi@fastmail.fm 2&amp;gt;&amp;amp;1| perl -e 'if (&amp;lt;STDIN&amp;gt; =~ m/password: &quot;(.*)&quot;$/ ) { print $1; }'`&quot;
    
set record          =   &quot;imaps://$my_server/INBOX.Sent Items&quot;
set postponed       =   &quot;imaps://$my_server/INBOX.Drafts&quot;
    
set from            =   &quot;xxx@fastmail.fm&quot;

# Account - SMTP

set smtp_url        = &quot;smtp://$my_user:$my_pass@$my_smtp_server:587&quot;
set smtp_pass       = $my_pass
set imap_user       = $my_user
set imap_pass       = $my_pass
set ssl_force_tls   = yes
set ssl_starttls    = no
    
#
# Default inbox
#
set spoolfile=imaps://$my_server/INBOX

#
# Default location of mailboxes
#
set folder=imaps://$my_server/INBOX
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This is good enough to start reading and sending emails with Fastmail. If you use gmail, there are plenty of tutorials out there that shows an equivalent configuration. You may have noticed that the &lt;code class=&quot;highlighter-rouge&quot;&gt;my_pass&lt;/code&gt; variable is using the &lt;code class=&quot;highlighter-rouge&quot;&gt;security&lt;/code&gt; command to retrieve the password from the OSX Keychain. I figured it was a good idea to remove my password from the .muttrc file, since I store all this stuff publicly on github.&lt;/p&gt;

&lt;p&gt;To add the password to the OSX Keychain, type:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo /usr/bin/security -v add-internet-password -a xxx@fastmail.fm -s mail.messagingengine.com -w your-password
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;contacts&quot;&gt;Contacts&lt;/h2&gt;

&lt;p&gt;mutt uses aliases to map a name to an email address. Aliases are stored in a file using a simple format:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;alias john John Doe &amp;lt;johndoe@email.com&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The default key binding to add an address from the currently opened mail is &lt;code class=&quot;highlighter-rouge&quot;&gt;a&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I store my contacts in a &lt;a href=&quot;https://owncloud.org/&quot;&gt;OwnCloud&lt;/a&gt; instance running on my server. Initially, I used a &lt;a href=&quot;https://github.com/l0b0/vcard2mutt/blob/master/v2m&quot;&gt;script&lt;/a&gt; to convert the vCard contacts into an alias flie, but it has been a sub-optimal solution, because I had to download the vCard file and re-import periodically.&lt;/p&gt;

&lt;p&gt;Enter &lt;a href=&quot;https://github.com/geier/pycarddav&quot;&gt;pycarddav&lt;/a&gt;. pycarddav is a CardDav CLI client with built in support for mutt’s &lt;code class=&quot;highlighter-rouge&quot;&gt;query_command&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The setup takes a couple of minutes:&lt;/p&gt;

&lt;p&gt;Install pycarddav:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;pip install pycarddav
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Create a &lt;a href=&quot;https://github.com/geier/pycarddav/blob/master/pycard.conf.sample&quot;&gt;configuration file&lt;/a&gt;  with the credentials of the CardDav server and syncronize:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;pycardsyncer
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Test:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;pc_query Barack
...
Name: Barack Obama
TEL (CELL, VOICE, pref): 123446767
TEL (WORK, VOICE): 999999999
EMAIL (INTERNET, HOME, pref): barack@whitehouse.org
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now, it is possible to configure mutt to search the contacts database using &lt;code class=&quot;highlighter-rouge&quot;&gt;TAB&lt;/code&gt; when composing. Add this entry to the mutt .muttrc file.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;set query_command=&quot;pc_query -m '%s'&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/mutt/mutt-blog-3.gif&quot; alt=&quot;auto completion&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;the-sidebar&quot;&gt;The sidebar&lt;/h2&gt;

&lt;p&gt;The sidebar it’s an handy right-side panel that shows a configurable number of IMAP folders and the number of messages that each folder contains.
I keep it hidden by default, and display it when needed.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/mutt/mutt-blog-2.gif&quot; alt=&quot;sidebar&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The folders displayed in the sidebar must be specified in the .muttrc file, like so:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mailboxes &quot;+-----------------&quot; \
      imaps://$my_server/INBOX \
      &quot;imaps://$my_server/INBOX.Sent Items&quot; \
      &quot;imaps://$my_server/INBOX.Drafts&quot; \
      &quot;+-- folders ------------&quot; \
      &quot;imaps://$my_server/INBOX.folder1&quot; \
      imaps://$my_server/INBOX.folder2 \
      imaps://$my_server/INBOX.folder3.subfolder \
      &quot;imaps://$my_server/INBOX.folder4&quot; \
      &quot;imaps://$my_server/INBOX.folder5&quot; \
      &quot;imaps://$my_server/INBOX.folder6&quot; \
      &quot;imaps://$my_server/INBOX.folder7&quot; \
      &quot;imaps://$my_server/INBOX.folder8&quot; \ 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;fine-tuning&quot;&gt;Fine-tuning&lt;/h2&gt;

&lt;p&gt;It’s easy to geek out with mutt’s configuration. There are tons on parameters. My approach is to start with a simple configuration and snoop at other’s people .muttrc files.
These are some settings that I have been using since start using mutt.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;set sort              = threads                     
set sort_aux          = reverse-last-date-received 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Gmail-style threading.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;set pager_stop
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Stop mutt showing the next message when we are at the end of the current message’s body.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;set fast_reply
set include     
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Quick reply, makes mutt to stop asking lots of questions.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;set reverse_name 
set envelope_from
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Pre-fills the “From” address when replying to emails, based on the email account that received the original mail. Useful in case of multiple accounts or multiple aliases (like in my case).&lt;/p&gt;

&lt;p&gt;As I mentioned early, I like writing in Vim. This is how I tell mutt to open Vim when composing an email:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;set editor = &quot;vim +/^$ ++1 -c 'set tw=76 expandtab nosmartindent spell'&quot;&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Here are a bunch of mutt dotfiles that I have used for inspiration.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/sysbot/dotmutt&quot;&gt;Bao Nguyen dot files&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://bethesignal.org/dotfiles/mutt/common.html&quot;&gt;Jeff Waugh mutt configuration&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.davep.org/mutt/muttrc/&quot;&gt;Dave Pearson mutt configuration&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/redondos/mutt&quot;&gt;Angelo Olivera dot files&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/hspak/dotfiles/tree/master/mutt&quot;&gt;Hong Shick Pak dot files&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;gpg&quot;&gt;GPG&lt;/h2&gt;

&lt;p&gt;mutt and GPG works pretty much hand in hand, no biggie, given that you have your GPG stuff all setup (I assume that if you made it so far, you are probably an avid GPG user). My configuration is shamelessly copied from &lt;a href=&quot;http://henrytodd.org/notes/2014/simpler-gnupg-mutt-config-with-gpgme/&quot;&gt;this&lt;/a&gt; 2014 article on mutt and GPG. Just remember to &lt;code class=&quot;highlighter-rouge&quot;&gt;brew&lt;/code&gt; mutt with the &lt;code class=&quot;highlighter-rouge&quot;&gt;--with-gpgme&lt;/code&gt; flag and install gpgme (&lt;code class=&quot;highlighter-rouge&quot;&gt;brew install gpgme&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;I like to sign all my outgoing mail. Easily done with this option set.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;set crypt_autosign=yes
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;With recent version of GPG, mutt output an error on startup that says &lt;code class=&quot;highlighter-rouge&quot;&gt;Using GPGME backend, although no gpg-agent is running&lt;/code&gt;. I think there is a &lt;a href=&quot;https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1309927.html&quot;&gt;patch&lt;/a&gt;  floating around, but I didn’t bother applying it, because it works.&lt;/p&gt;

&lt;h2 id=&quot;markdown&quot;&gt;Markdown&lt;/h2&gt;

&lt;p&gt;I use Roguelazer’s &lt;a href=&quot;https://github.com/Roguelazer/muttdown&quot;&gt;muttdown&lt;/a&gt; to send HTML email written in markdown. Before muttdown, which is a quite recent project, I was using a mutt macro based on pandoc (something similar to what is described &lt;a href=&quot;http://unix.stackexchange.com/questions/108485/send-email-written-in-markdown-using-mutt#108809&quot;&gt;here&lt;/a&gt;). muttdown is a sendmail replacement that transparently compiles annotated &lt;code class=&quot;highlighter-rouge&quot;&gt;text/plain&lt;/code&gt; mail into &lt;code class=&quot;highlighter-rouge&quot;&gt;text/html&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I just need to start my message with &lt;code class=&quot;highlighter-rouge&quot;&gt;!m&lt;/code&gt; to trigger the markdown compilation.&lt;/p&gt;

&lt;p&gt;To use muttdown:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git clone https://github.com/Roguelazer/muttdown.git
cd muttdown
python setup.py install
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Create a configuration file, .muttdown.yaml&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;smtp_host: mail.messagingengine.com
smtp_port: 587
smtp_ssl: false
smtp_username: xxx@fastmail.fm
smtp_password_command: security find-internet-password -w -a xxx@fastmail.fm        
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;In &lt;code class=&quot;highlighter-rouge&quot;&gt;.muttrc&lt;/code&gt; add:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;set sendmail = &quot;muttdown -c /path/to/.muttdown.yaml&quot; 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;bindings-and-macros&quot;&gt;Bindings and macros&lt;/h2&gt;

&lt;p&gt;The default key binding for mutt is quite reasonable. mutt allows to bind the same keystroke to different action in each view (index, pager, browser, attach, etc. - mutt calls the views “menus”).&lt;/p&gt;

&lt;p&gt;I favor a Vim-like binding, mostly for navigating the email list and the email body.&lt;/p&gt;

&lt;p&gt;mutt offers rudimentary &lt;a href=&quot;http://dev.mutt.org/trac/wiki/MuttGuide/Macros&quot;&gt;macros&lt;/a&gt; as well. Macros in mutt are essentially a way to automate keystrokes.&lt;/p&gt;

&lt;p&gt;To get an idea of how a macro looks like, take a look at this macro. It is triggered by the &lt;code class=&quot;highlighter-rouge&quot;&gt;TAB&lt;/code&gt; key and it’s only available in the index menu (the message list). When triggered, it shows the next unread message and press &lt;code class=&quot;highlighter-rouge&quot;&gt;enter&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;macro index   &amp;lt;tab&amp;gt;      &amp;lt;next-unread&amp;gt;&amp;lt;enter&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/luciano-fiandesio/dotfiles/blob/master/.mutt/bindings.muttrc&quot;&gt;Here&lt;/a&gt; is my binding file.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://sheet.shiar.nl/mutt&quot;&gt;This&lt;/a&gt; is an awesome, interactive mutt cheatsheet for getting started with the key binding.&lt;/p&gt;

&lt;h2 id=&quot;html-emails&quot;&gt;HTML emails&lt;/h2&gt;

&lt;p&gt;You can throw any kind of attachment to mutt, as long as the type is specified in a &lt;a href=&quot;https://github.com/luciano-fiandesio/dotfiles/blob/master/.mutt/mailcap&quot;&gt;mailcap&lt;/a&gt; file. My mailcap file looks like this:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;application/msword; ~/.mutt/view_attachment.sh %s &quot;-&quot; '/Applications/TextEdit.app'
#
# # Images
image/jpg; ~/.mutt/view_attachment.sh %s jpg
image/jpeg; ~/.mutt/view_attachment.sh %s jpg
image/pjpeg; ~/.mutt/view_attachment.sh %s jpg
image/png; ~/.mutt/view_attachment.sh %s png
image/gif; ~/.mutt/view_attachment.sh %s gif
#
# # PDFs
application/pdf; ~/.mutt/view_attachment.sh %s pdf

#
# # HTML
text/html; ~/.mutt/view_attachment.sh %s html; copiousoutput
#
# # Unidentified files
application/octet-stream; ~/.mutt/view_attachment.sh %s &quot;-&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The “mailcap” file is just a way to map a MIME type to an application that can handle it. I’m using the &lt;a href=&quot;https://github.com/luciano-fiandesio/dotfiles/blob/master/.mutt/view_attachment.sh&quot;&gt;view_attachment.sh&lt;/a&gt; script, which is mentioned in &lt;a href=&quot;http://stevelosh.com/blog/2012/10/the-homely-mutt/&quot;&gt;the mother of all mutt articles&lt;/a&gt;. It works well for me.&lt;/p&gt;

&lt;p&gt;Once the “mailcap” file is sorted, mutt can auto-open HTML emails with an entry in the .muttrc file:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  auto_view text/html                                      # view html automatically
  alternative_order text/plain text/enriched text/html     # save html for last
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/mutt/mutt-blog-4.gif&quot; alt=&quot;autoopen&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;colors&quot;&gt;Colors&lt;/h2&gt;

&lt;p&gt;I’m lazy, so I use the Solarized theme for mutt, available &lt;a href=&quot;https://github.com/altercation/mutt-colors-solarized&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;</content><author><name>Luciano Fiandesio</name><email>luciano@fiandes.io</email></author><category term="mutt" /><category term="email" /><category term="gpg" /><summary type="html">20/08/2016 I wrote a short upgrade to this guide, that uses the newly released mutt 1.7.0.</summary></entry><entry><title type="html">1Password on Linux</title><link href="http://fiandes.io/1password-in-linux/" rel="alternate" type="text/html" title="1Password on Linux" /><published>2015-02-22T00:00:00+00:00</published><updated>2015-02-22T00:00:00+00:00</updated><id>http://fiandes.io/1password-in-linux</id><content type="html" xml:base="http://fiandes.io/1password-in-linux/">&lt;p&gt;Lately, my long-lasting love for Apple products has been fading. I ditched my iPhone 6+ for a &lt;a href=&quot;https://oneplus.net/&quot;&gt;OnePlus One&lt;/a&gt; and I relegated my MBP to mostly photo-editing tasks. I’m typing this from a fresh installation of &lt;a href=&quot;http://xubuntu.org/&quot;&gt;Xubuntu 14.10&lt;/a&gt;, which I have been using in the past and I tend to prefer  to the heavy-weight Ubuntu.&lt;/p&gt;

&lt;p&gt;My totally most used app in the Apple eco-system is &lt;a href=&quot;https://agilebits.com/onepassword&quot;&gt;Agile Bits 1Password&lt;/a&gt;. In fact, what I miss most in my new Android phone is the fingerprint reader integration with 1Password. I have to type my rather long and cumbersome password every time I need to look for a piece of encrypted info. Agile Bits doesn’t support Linux at all. For Linux users, they offer a web interface called &lt;a href=&quot;https://guides.agilebits.com/1password-mac/5/en/topic/1passwordanywhere&quot;&gt;1Password Anywhere&lt;/a&gt;. It’s Javascript based and runs locally. Sub-optimal, if you ask me.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/1password-linux/1password_4_large.png&quot; alt=&quot;Silvrback blog image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;So, during the Xubuntu setup process, I started googling around for some recent solutions to running 1Password on Linux and I stumbled on the awesome, little &lt;a href=&quot;http://hg.icculus.org/icculus/1pass/&quot;&gt;repo&lt;/a&gt; of &lt;a href=&quot;https://plus.google.com/+RyanGordon/posts/ZFyb9TQS9zB&quot;&gt;Ryan Gordon&lt;/a&gt;. Ryan has hacked together a Lua script, named &lt;strong&gt;1pass&lt;/strong&gt;, which can decrypt the 1Password keychain and show whatever info you store in 1Password in a very minimalistic GUI.&lt;/p&gt;

&lt;p&gt;The setup wasn’t exactly straightforward, but eventually I got it to work. Here is  quick rundown of the steps required to get going with 1pass.&lt;/p&gt;

&lt;p&gt;InstaIl &lt;a href=&quot;http://www.selenic.com/mercurial/&quot;&gt;Mercurial&lt;/a&gt;, to fetch the 1pass repo.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install mercurial
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Clone Ryan’s repo, 1pass:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hg clone http://hg.icculus.org/icculus/1pass/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Install some dependencies:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install libgtk2.0-dev libxtst-dev
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Run the build:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cd 1pass
./build.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If 1pass built without errors, copy (or better symlink from Dropbox) the keychain in 1pass folder.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mkdir 1Password
ln -s ~/Dropbox/xx/yy/zz/1Password.agilekeychain/ 1Password/1Password.agilekeychain
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You can finally try out 1pass, by typing:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;./1pass
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The script welcomes the user with a rather cryptic message:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Now waiting for the magic key combo (probably Alt-Meta-\) ...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The “magic combo, on my Lenovo X220, is  “Windows Key+Alt+&quot;
I had to figure it out by checking out a &lt;strong&gt;&lt;a href=&quot;http://hg.icculus.org/icculus/1pass/file/5155ff0e6d3d/keyhook.c&quot;&gt;keyhook.c&lt;/a&gt;&lt;/strong&gt; file, located in the project’s root.
For the binding to work, you need to press the keys in the right sequence, which is:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Alt -&amp;gt; Win -&amp;gt; \
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;By pressing the keys at the same time, or the Win key first, will cause the popup to stay well hidden.&lt;/p&gt;

&lt;p&gt;This is the password prompt box that pops-up on pressing the “magic combo”.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/1password-linux/1pass_1_large.jpg&quot; alt=&quot;Silvrback blog image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;On successful password entry, a floating menu displaying the categories in the keychain should appear. You can then navigate through the categories, select the password, press Enter and the password will be copied in the clipboard.
The key binding works everywhere, so it is possible to access the encrypted info’s  menu from the browser or whatever application.&lt;/p&gt;

&lt;p&gt;To avoid leaving a terminal tab opened just for 1pass, I go like this:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;./1pass &amp;amp; exit
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Edit:&lt;/p&gt;

&lt;p&gt;This post was picked up by Hacker News. As usual, lots of interesting pointers. Follow the conversation here: &lt;a href=&quot;https://news.ycombinator.com/item?id=9091691&quot;&gt;https://news.ycombinator.com/item?id=9091691&lt;/a&gt;&lt;/p&gt;</content><author><name>Luciano Fiandesio</name><email>luciano@fiandes.io</email></author><category term="1password" /><category term="linux" /><summary type="html">Lately, my long-lasting love for Apple products has been fading. I ditched my iPhone 6+ for a OnePlus One and I relegated my MBP to mostly photo-editing tasks. I’m typing this from a fresh installation of Xubuntu 14.10, which I have been using in the past and I tend to prefer to the heavy-weight Ubuntu.</summary></entry><entry><title type="html">Vim configuration for happy Java coding</title><link href="http://fiandes.io/vim-configuration-for-happy-java-coding/" rel="alternate" type="text/html" title="Vim configuration for happy Java coding" /><published>2013-10-04T00:00:00+00:00</published><updated>2013-10-04T00:00:00+00:00</updated><id>http://fiandes.io/vim-configuration-for-happy-java-coding</id><content type="html" xml:base="http://fiandes.io/vim-configuration-for-happy-java-coding/">&lt;p&gt;During the last couple of years, I gradually moved to Vim for editing text and writing code. It’s not an easy journey: Vim requires dedication and it’s sheer amount of options and plugins can be intimidating for a newcomer. However, with enough perseverance, the VIM’s approach to manipulating text becomes natural and you will not look back (enough with the Vim advocating, there are &lt;a href=&quot;http://stevelosh.com/blog/2010/09/coming-home-to-vim/&quot;&gt;countless&lt;/a&gt; &lt;a href=&quot;http://dysfunctionalprogramming.co.uk/blog/2013/08/15/fight-with-tools/&quot;&gt;blog&lt;/a&gt; &lt;a href=&quot;http://www.naildrivin5.com/blog/2013/04/24/how-to-switch-to-vim.html&quot;&gt;posts&lt;/a&gt; discussing the marvels of Vim).&lt;/p&gt;

&lt;p&gt;In this post, I’m presenting &lt;strong&gt;my current Vim&lt;/strong&gt; configuration for working with Java and Groovy projects.
There are lots of folks who run away screaming when you try to suggest they abandon one of the mainstream IDEs (Eclipse, IntelliJ, Netbeans) and move to Vim. How will you do without auto-completion? How do you navigate files? How do you refactor? How do you jump to a function definition? It turns out that you can do most of that stuff in VIM. Refactoring it’s probably the only functionality that is hard to achieve, even if it’s not an impossible goal (&lt;a href=&quot;http://eclim.org/&quot;&gt;Eclim&lt;/a&gt; partially supports that).&lt;/p&gt;

&lt;p&gt;I’m not going to try to &lt;strong&gt;convince you&lt;/strong&gt; that Vim is better than your favorite Java IDE, especially if you have never used Vim before. I have never felt very comfortable working inside one of the heavyweight IDEs and my productivity is just higher when I work with my VIM setup. Your mileage may vary, but I encourage you to take a spin.&lt;/p&gt;

&lt;p&gt;(As a side note, James Gosling famously &lt;a href=&quot;http://www.computerworld.com.au/article/207799/don_t_use_emacs_says_java_father/&quot;&gt;stated&lt;/a&gt;  that you’d better use an IDE if you want to code in Java.)&lt;/p&gt;

&lt;p&gt;This setup has been tested on OSX 10.8 and MacVim.&lt;/p&gt;

&lt;h2 id=&quot;setup&quot;&gt;Setup&lt;/h2&gt;

&lt;p&gt;I assume you use &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2332&quot;&gt;Pathogen&lt;/a&gt; for managing your VIM plugins. If you don’t, I highly recommend you do (or look into other bundle managers, like &lt;a href=&quot;https://github.com/gmarik/vundle&quot;&gt;Vundle&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;If you are on a Mac you should use &lt;a href=&quot;https://code.google.com/p/macvim/&quot;&gt;MacVim&lt;/a&gt; and you should install it using &lt;a href=&quot;http://brew.sh/&quot;&gt;Homebrew&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;java-and-groovy-syntax-highlighting&quot;&gt;Java and Groovy syntax highlighting&lt;/h2&gt;

&lt;p&gt;MacVim comes with a truckload of syntax highlighting files, including Java and Groovy.&lt;/p&gt;

&lt;p&gt;In order for syntax highlighting to work, add&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;syntax on 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;to your &lt;code class=&quot;highlighter-rouge&quot;&gt;.vimrc&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;This is how Java and Groovy files look like in Vim:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/vim-java/01_vim_java.jpg&quot; alt=&quot;Syntax highlighting&quot; /&gt;&lt;/p&gt;

&lt;p&gt;If you are using a recent version of MacVim (7.4 or higher) chances are that the Groovy syntax file is &lt;a href=&quot;https://groups.google.com/forum/?fromgroups#!topic/vim_dev/4m4FJGmkgb0&quot;&gt;broken&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In order to fix the syntax issue, open the &lt;code class=&quot;highlighter-rouge&quot;&gt;groovy.vim&lt;/code&gt; file located in &lt;code class=&quot;highlighter-rouge&quot;&gt;/usr/local/Cellar/macvim/7.4-xx/MacVim.app/Contents/Resources/vim/runtime/syntax&lt;/code&gt; and comment out line &lt;strong&gt;260&lt;/strong&gt;.&lt;/p&gt;

&lt;h2 id=&quot;snippets&quot;&gt;Snippets&lt;/h2&gt;

&lt;p&gt;Snippets are essential to decrease typing and increase the speed of development. All modern IDEs support snippets (also known as templates) with different level of configurability.&lt;/p&gt;

&lt;p&gt;After testing different snippet plugins for Vim, I settled with &lt;strong&gt;&lt;a href=&quot;https://github.com/SirVer/ultisnips&quot;&gt;UltiSnips&lt;/a&gt;&lt;/strong&gt;. It requires a version of Vim compiled with Python. If you use MacVim installed with Homebrew, you should be all set.&lt;/p&gt;

&lt;p&gt;To check if your Vim installation is compiled with Python support, type:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ vim --version | grep python
+cryptv   +linebreak    +python    +viminfo
+cscope   +lispindent   -python3   +vreplace
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If you see &lt;code class=&quot;highlighter-rouge&quot;&gt;+python&lt;/code&gt; you are good to go.&lt;/p&gt;

&lt;p&gt;Install UltiSnips in your &lt;code class=&quot;highlighter-rouge&quot;&gt;~/.vim/bundle&lt;/code&gt; folder:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git clone https://github.com/SirVer/ultisnips.git 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Ultisnips has several Java &lt;a href=&quot;https://raw.github.com/SirVer/ultisnips/master/UltiSnips/java.snippets&quot;&gt;snippets&lt;/a&gt; already configured and ready to use. You can create new snippets by adding a &lt;code class=&quot;highlighter-rouge&quot;&gt;java.snippets&lt;/code&gt; file to a &lt;code class=&quot;highlighter-rouge&quot;&gt;~/.vim/snippets&lt;/code&gt; folder.&lt;/p&gt;

&lt;p&gt;If you add your own snippets, do not forget to configure Ultisnips to access also your own snippets.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;let g:UltiSnipsSnippetDirectories=[&quot;UltiSnips&quot;, &quot;snippets&quot;]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This is an example of UltiSnips in action:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/vim-java/02_snippets.gif&quot; alt=&quot;Ultisnips&quot; /&gt;&lt;/p&gt;

&lt;p&gt;UltiSnips snippets use placeholders for inserting custom data:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;snippet co &quot;constant&quot; b
public static final ${1:String} ${2:var} = $3;$0
endsnippet
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The previous snippet (triggered by &lt;code class=&quot;highlighter-rouge&quot;&gt;co&lt;/code&gt;) create the following statement:&lt;/p&gt;

&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;final&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;and places the cursor on &lt;code class=&quot;highlighter-rouge&quot;&gt;String&lt;/code&gt;. By pressing &amp;lt;CTRL+j&amp;gt; you can move the cursor to the remaining placeholders, defined with &lt;code class=&quot;highlighter-rouge&quot;&gt;${1}&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;${2}&lt;/code&gt; and so on. The placeholder marked with &lt;code class=&quot;highlighter-rouge&quot;&gt;${0}&lt;/code&gt; is always the last one the cursor will move to.&lt;/p&gt;

&lt;h2 id=&quot;indent-highlight&quot;&gt;Indent highlight&lt;/h2&gt;

&lt;p&gt;Java and Groovy code can display several levels of indentation. To help keeping track of the code blocks I use the &lt;strong&gt;&lt;a href=&quot;https://github.com/Yggdroot/indentLine.git&quot;&gt;IndentLine&lt;/a&gt;&lt;/strong&gt; plugin. There are several other &lt;a href=&quot;https://github.com/nathanaelkane/vim-indent-guides&quot;&gt;plugins&lt;/a&gt;  that offer the same functionality, but I kind of like the simplicity of this one.&lt;/p&gt;

&lt;p&gt;To install IndentLine, clone the repo into your &lt;code class=&quot;highlighter-rouge&quot;&gt;~/.vim/bundle&lt;/code&gt; folder:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git clone https://github.com/Yggdroot/indentLine.git
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I configure mine like so:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&quot; vertical line indentation
let g:indentLine_color_term = 239
let g:indentLine_color_gui = '#09AA08'
let g:indentLine_char = '│'
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Please note that Vim natively supports visual guides for tab-indented blocks. This StackOverflow &lt;a href=&quot;http://stackoverflow.com/a/2159997&quot;&gt;answer&lt;/a&gt; clearly shows the settings to enable indentation guide and remove tabs before saving a file.&lt;/p&gt;

&lt;h2 id=&quot;auto-completion&quot;&gt;Auto completion&lt;/h2&gt;

&lt;p&gt;Vim basic auto completion for Java is an essential feature for working with third-part libraries and large code bases.
On my quest for the perfect Java/Vim setup, I started using &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=1785&quot;&gt;Javacomplete&lt;/a&gt; which never really worked as well as any IDE in terms of auto completion. I knew of the existence of &lt;strong&gt;&lt;a href=&quot;http://eclim.org/&quot;&gt;Eclim&lt;/a&gt;&lt;/strong&gt; but I kind feel like cheating to resort to an headless Eclipse for my auto completion needs. Additionally, I considered the setup a bit too complex.
Eventually, I decided to try out Eclim and have been very satisfied with the Vim integration. Eclim documentation is excellent and the bundle integrates well with other plugins, like &lt;a href=&quot;https://github.com/ervandew/supertab&quot;&gt;supertab&lt;/a&gt; (more on supertab later).&lt;/p&gt;

&lt;p&gt;The only drawback is that you need to install &lt;a href=&quot;http://eclipse.org/downloads/index.php&quot;&gt;Eclipse&lt;/a&gt;. I consider IntelliJ a superior platform but I still use Eclipse with the &lt;a href=&quot;http://puppetlabs.com/blog/geppetto-a-puppet-ide&quot;&gt;Geppetto&lt;/a&gt; plugin to edit Puppet files.&lt;/p&gt;

&lt;h3 id=&quot;installing-eclim&quot;&gt;Installing Eclim&lt;/h3&gt;

&lt;p&gt;The installation &lt;a href=&quot;http://eclim.org/install.html&quot;&gt;page&lt;/a&gt; for Eclim is quite comprehensive. The basic installation steps are:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;wget http://downloads.sourceforge.net/project/eclim/eclim/2.3.2/eclim_2.3.2.jar
java -jar eclim_2.3.2.jar
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;eclim 2.3.2 is the package to download if you have Eclipse 4.3.x (Kepler). There is a different &lt;a href=&quot;https://downloads.sourceforge.net/project/eclim/eclim/1.7.18/eclim_1.7.18.jar&quot;&gt;package&lt;/a&gt; for older versions of Eclipse.&lt;/p&gt;

&lt;p&gt;The installer has a graphical interface and it only requires to select the current Eclipse installation and additional packages (for example, Scala). It takes just a couple of minutes.&lt;/p&gt;

&lt;p&gt;Once the installation is completed, you want to start the Eclipse headless daemon using:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ECLIPSE_HOME/eclimd
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The boot procedure takes around 30 seconds.&lt;/p&gt;

&lt;p&gt;To test that Vim can “talk” to Eclipse, open Vim and type&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;:PingEclim
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If your output says something like&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;eclim   2.3.2
eclipse 4.3.0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;you should have a working integration.&lt;/p&gt;

&lt;p&gt;Finally, you must &lt;a href=&quot;http://eclim.org/vim/core/project.html#projectcreate&quot;&gt;create&lt;/a&gt; a new Eclipse project or &lt;a href=&quot;http://eclim.org/vim/core/project.html#projectimport&quot;&gt;import&lt;/a&gt; an existing one.&lt;/p&gt;

&lt;p&gt;My workflow revolves around &lt;a href=&quot;http://www.gradle.org/&quot;&gt;Gradle&lt;/a&gt;, a Groovy based build tool which is getting a phenomenal amount of traction. This is what I do (using a &lt;a href=&quot;https://github.com/luciano-fiandesio/dotfiles/blob/master/.functions#L234&quot;&gt;script&lt;/a&gt;):&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;mkdir &lt;/span&gt;my-awesome-project &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$_&lt;/span&gt;
gradle setupBuild &lt;span class=&quot;nt&quot;&gt;--type&lt;/span&gt; java-library
perl &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-lne&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'print $_;print &quot;apply plugin: \x27eclipse\x27&quot; if(/apply/);'&lt;/span&gt; build.gradle    
gradle eclipse
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then from inside Vim:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;:ProjectImport .
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The first line creates a new folder named &lt;code class=&quot;highlighter-rouge&quot;&gt;my-awesome-project&lt;/code&gt;. The second line calls Gradle’s project generation feature (similar to Maven &lt;a href=&quot;https://maven.apache.org/guides/introduction/introduction-to-archetypes.html&quot;&gt;archetypes&lt;/a&gt;). The third line adds the Eclipse plugin to the Gradle build file.
Finally I invoke &lt;code class=&quot;highlighter-rouge&quot;&gt;gradle plugin&lt;/code&gt; to generate the Eclipse project files.&lt;/p&gt;

&lt;p&gt;In this short video, you can see a couple of Eclim’s features:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Automatically adding an import (&lt;code class=&quot;highlighter-rouge&quot;&gt;:JavaImport&lt;/code&gt;)&lt;/li&gt;
  &lt;li&gt;Automatically adding a getter and setter (&lt;code class=&quot;highlighter-rouge&quot;&gt;:JavaGetSet&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/vim-java/03_eclim.gif&quot; alt=&quot;Eclim&quot; /&gt;&lt;/p&gt;

&lt;p&gt;For a complete list of Eclim commands, please refer to this &lt;a href=&quot;http://eclim.org/cheatsheet.html&quot;&gt;cheatsheet&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;supertab&quot;&gt;Supertab&lt;/h3&gt;

&lt;p&gt;The second auto completition plugin is &lt;a href=&quot;https://github.com/ervandew/supertab&quot;&gt;Supertab&lt;/a&gt;. It essentially allows completing using the &amp;lt;TAB&amp;gt; key instead of the standard &amp;lt;CTRL+X&amp;gt;&amp;lt;CTRL+N&amp;gt;, when in insert mode. It plays nicely with Eclim, even though some fiddling is &lt;a href=&quot;https://github.com/luciano-fiandesio/dotfiles/blob/master/.vim/config/supertab.vim&quot;&gt;required&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To install Supertab, clone the repo in your &lt;code class=&quot;highlighter-rouge&quot;&gt;.vim/bundle&lt;/code&gt; folder:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git clone https://github.com/ervandew/supertab.git
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;delimitmate&quot;&gt;Delimitmate&lt;/h3&gt;

&lt;p&gt;DelimitMate provides automatic closing of quotes, parenthesis, brackets, etc. A real time saver. The plugin works pretty well out-of-the-box and I didn’t find any compatibility issue with the other plugins.&lt;/p&gt;

&lt;p&gt;To install Delimitmate, clone the repo in your Pathogen &lt;code class=&quot;highlighter-rouge&quot;&gt;bundle&lt;/code&gt; folder.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git clone https://github.com/Raimondi/delimitMate.git
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This is the only setting I have modified for this plugin:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;let delimitMate_expand_cr = 1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Check out &lt;code class=&quot;highlighter-rouge&quot;&gt;help delimitMate&lt;/code&gt; to learn about other options that may better serve your workflow.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/vim-java/04_delimitmate.gif&quot; alt=&quot;Delimitmate&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;file-browsing&quot;&gt;File browsing&lt;/h2&gt;

&lt;p&gt;Eclim can display a project navigation pane by issuing the &lt;code class=&quot;highlighter-rouge&quot;&gt;:ProjectTree&lt;/code&gt; command, but I still prefer &lt;a href=&quot;https://github.com/scrooloose/nerdtree&quot;&gt;NERD tree&lt;/a&gt; to visualize my project’s files.&lt;/p&gt;

&lt;p&gt;NERD tree is a very popular plugin with tons of documentation: these &lt;a href=&quot;http://majorursa.net/blog/2013/05/06/vim-and-nerdtree-awesome-ness/&quot;&gt;blog&lt;/a&gt; &lt;a href=&quot;http://blog.htbaa.com/news/vim-essentials-nerd-tree&quot;&gt;posts&lt;/a&gt; contain all the information to get you started with this plugin.&lt;/p&gt;

&lt;p&gt;Install NERD tree by cloning the Github repo in your &lt;code class=&quot;highlighter-rouge&quot;&gt;bundle&lt;/code&gt; folder.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git clone https://github.com/scrooloose/nerdtree
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;My NERD tree &lt;a href=&quot;https://github.com/luciano-fiandesio/dotfiles/blob/master/.vim/config/nerdtree.vim&quot;&gt;configuration&lt;/a&gt;  is kept to a minimum: I have only mapped &amp;lt;CTRL-d&amp;gt; to toggle the file browsing pane.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;nmap &amp;lt;leader&amp;gt;d :NERDTreeToggle&amp;lt;CR&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;ctrlp&quot;&gt;CtrlP&lt;/h3&gt;

&lt;p&gt;If you have been using Vim for a while, &lt;a href=&quot;https://github.com/kien/ctrlp.vim&quot;&gt;CtrlP&lt;/a&gt; is surely in your &lt;code class=&quot;highlighter-rouge&quot;&gt;bundle&lt;/code&gt; folder. It’s a fuzzy finder for files, buffers, MRU and even tags. I have mapped CtrlP to &amp;lt;CTRL+t&amp;gt; and I can use the binding to type the first letters of the file I want to open.
CtrlP is the equivalent of &amp;lt;CTRL + ALT + N&amp;gt; in IntelliJ Idea and &amp;lt;CTRL-SHIFT-T&amp;gt; in Eclipse.&lt;/p&gt;

&lt;p&gt;For example, if I want to open a file named &lt;code class=&quot;highlighter-rouge&quot;&gt;LibraryTest.java&lt;/code&gt; I can type &amp;lt;CTRL+t LT&amp;gt; (LT = &lt;strong&gt;L&lt;/strong&gt;ibrary&lt;strong&gt;T&lt;/strong&gt;est). This plugin is indispensable when working on large projects with hundreds of files.&lt;/p&gt;

&lt;p&gt;Install CtrlP by cloning the repo in your Pathogen’s &lt;code class=&quot;highlighter-rouge&quot;&gt;bundle&lt;/code&gt; folder:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git clone https://github.com/kien/ctrlp.vim
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;These are my setting for the plugin:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&quot; Use &amp;lt;leader&amp;gt;t to open ctrlp
let g:ctrlp_map = '&amp;lt;leader&amp;gt;t'
&quot; Ignore these directories
set wildignore+=*/build/**
&quot; disable caching
let g:ctrlp_use_caching=0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;building&quot;&gt;Building&lt;/h2&gt;

&lt;p&gt;The last part of my Vim setup is related to building and running Java or Groovy tests. As I have mentioned previously, I use Gradle to build my Java/Groovy projects.&lt;/p&gt;

&lt;p&gt;Gradle works similarly to Ant or Maven. A &lt;code class=&quot;highlighter-rouge&quot;&gt;build.gradle&lt;/code&gt; file is placed in the project’s root directory and a Gradle process runs the build based on the build file content.&lt;/p&gt;

&lt;p&gt;A Gradle build is launched from the command line like so:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;gradle clean build
gradle test
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Vim is built with support for compiler integration and the MacVim distribution comes with over 60 compiler configurations. Unfortunately Gradle is not among the supported compilers so I had to create my &lt;a href=&quot;https://github.com/luciano-fiandesio/dotfiles/blob/master/.vim/compiler/gradle.vim&quot;&gt;own&lt;/a&gt; Gradle compiler file, with a little help from &lt;a href=&quot;https://github.com/niklasl&quot;&gt;Niklas&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;With the Gradle compiler file in place, I can now set the compiler to Gradle using &lt;code class=&quot;highlighter-rouge&quot;&gt;:compiler gradle&lt;/code&gt; and run my tests by typing &lt;code class=&quot;highlighter-rouge&quot;&gt;make test&lt;/code&gt;. This solution works for both Java and Groovy projects, as long as you use Gradle as a build tool.
I have mapped everything to the &amp;lt;F4&amp;gt; key, like so:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;map &amp;lt;F4&amp;gt; :w&amp;lt;CR&amp;gt; :compiler gradle&amp;lt;CR&amp;gt; :make test&amp;lt;CR&amp;gt;:cw 4&amp;lt;CR&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;When pressing &amp;lt;F4&amp;gt;, Vim saves the current file, run the Gradle compilation and open the &lt;a href=&quot;http://vimdoc.sourceforge.net/htmldoc/quickfix.html&quot;&gt;QuickFix&lt;/a&gt; window if there are compilation errors or test do not pass.&lt;/p&gt;

&lt;p&gt;There is one gotcha: the QuickFix window is supposed to show compilation errors that you can “navigate” using &amp;lt;:cn&amp;gt; or &amp;lt;:cp&amp;gt; and even jump to the file reported in the errors list. This functionality is based on the assumption that the compiler output is properly parsed, which is not the case for Gradle. Still, I’m able to display the compilation/test errors in the QuickFix window.&lt;/p&gt;

&lt;p&gt;I’m currently working on a solution (based on &lt;a href=&quot;http://forums.gradle.org/gradle/topics/retrieve_failed_test_file_and_line_number&quot;&gt;this&lt;/a&gt; forum entry) for having Gradle and the QuickFix window to play together nicely.&lt;/p&gt;

&lt;p&gt;This is how the test feedback loop looks like:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/vim-java/05_testdemo.gif&quot; alt=&quot;Test loop&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;maven&quot;&gt;Maven&lt;/h3&gt;

&lt;p&gt;In case you Maven is your build tool of choice, you can use Eclim to &lt;a href=&quot;http://eclim.org/vim/java/maven.html#mvn&quot;&gt;build&lt;/a&gt; the project using the Eclim command &lt;code class=&quot;highlighter-rouge&quot;&gt;:Mvn&lt;/code&gt;.&lt;/p&gt;

&lt;h3 id=&quot;vim-rooter&quot;&gt;vim-rooter&lt;/h3&gt;

&lt;p&gt;One more plugin is required for the compilation to work correctly in my setup. By default, the &lt;code class=&quot;highlighter-rouge&quot;&gt;:make&lt;/code&gt; command is executed inside the directory of the currently open file. If I have a test case opened in &lt;code class=&quot;highlighter-rouge&quot;&gt;src/test/java/my/awesome/package&lt;/code&gt; and I call &lt;code class=&quot;highlighter-rouge&quot;&gt;:make&lt;/code&gt;, the Gradle process will be executed inside that directory and will obviously fail. Gradle requires a &lt;code class=&quot;highlighter-rouge&quot;&gt;build.gradle&lt;/code&gt; in order to work.
We need Vim to change the current directory to the project’s root folder. The &lt;a href=&quot;https://github.com/airblade/vim-rooter&quot;&gt;vim-rooter&lt;/a&gt; plugin has this exact functionality. It detects the project root by the presence of known directories, like .git or files like Rakefile.&lt;/p&gt;

&lt;p&gt;It’s a simple plugin that doesn’t require any additional configuration. To install it, clone the Github repo into your &lt;code class=&quot;highlighter-rouge&quot;&gt;bundle&lt;/code&gt; folder.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git clone https://github.com/airblade/vim-rooter.git
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I hope that this rather lengthy guide will encourage you to try out Vim for your daily development activities.&lt;/p&gt;</content><author><name>Luciano Fiandesio</name><email>luciano@fiandes.io</email></author><category term="vim" /><category term="java" /><category term="groovy" /><summary type="html">During the last couple of years, I gradually moved to Vim for editing text and writing code. It’s not an easy journey: Vim requires dedication and it’s sheer amount of options and plugins can be intimidating for a newcomer. However, with enough perseverance, the VIM’s approach to manipulating text becomes natural and you will not look back (enough with the Vim advocating, there are countless blog posts discussing the marvels of Vim).</summary></entry></feed>