Thoughts on Linux on the Desktop

DISCLAIMER I know very little about Linux but I want to change that. This post is written with the possibility of complete incompetence in mind. Please limit the hate. Thanks.

I am feeling adventurous this month: I contemplated Linux on the Desktop. My Mac does perfectly fine, but I really want to try something new. But here’s the thing: There are literally dozens of Linux flavours out there. Here’s my take on some of them in a dilettante (and incomplete!) list in no particular order.

CentOS Probably the one I spent most of my time with so far. I consider this as a server-only kind of operating system that is boring but reliable and solid for its purpose. In fact, this site is served on a CentOS system.

Debian with GNOME Debian is kind of “boring” too, but I honor the simplicity and purity of the system. As far as Desktops go, I prefer the GNOME Desktop Environment over KDE (not just on Debian). Debian is considered rock-solid and probably has the most packages available in its repositories.

Ubuntu GNOME I can’t stand the look of the newer Unitiy Desktop Environment that ships with the newer versions of Ubuntu but I like Ubuntu with GNOME. The problem is: there is an inconsistency in the look between the GNOME applications and other packages (e.g. VLC) that ruin this Linux flavor for me. Debian (from which Ubuntu is derived from) is more appealing to me.

Ubuntu MATE The MATE Desktop looks strange to me but a lot of people seem to quite like it. It’s definitely something I will look into more in the future.

Fedora This is propably the most cutting-edge Linux distribution out there, as it is the prototype OS for features which are later shipped in stable form for releases in Red Hat, a commercially distributed version of Linux. It supports the newest version of GNOME to this date (3.20) and the cutting-edge feeling is something I care deeply about1.

Kali I love Kali. You can have much fun with it.2 Not a suitable desktop OS though.

Linux Mint This one is recommended by most people for most people (I guess?), but I just can’t see the beauty of it. Something more I have to look more into.

I am almost sold on Fedora. It features GNOME, is always up-to-date and seems to perform just fine. It also utilizes yum as its package manager. I don’t know much about Linux package managers but I am far more familiar with apt and I also think there are many more packages available in the Debian(-derived) distributions.

Tough choice.


  1. I am a guy who installs a beta OS on his phone after all

  2. Watch Mr. Robot

Series tip: Silicon Valley


I highly recommend this series. I binged through all of the episodes in the last three days. Prepare for season 3 finale on June 26th.

Give it a try!

Are You Social or Depressed?

Last week a friend told me: “Social networks depress you”. I have to say she’s kind of right.

Staying connected or staying up-to-date with friends they say. But the posts on facebook and pictures on instagram aren’t about staying connected in the first place. They are about prestige. A constant pressure that forces everyone to impress his or her peers with their “daily life” and flamboyant lifestyle. It’s a race for the most popular and coolest. But it’s a distortion of reality. These posts are a falsification of their lives, tailored to the poster’s desires and wishes. Once realized, it cannot be unseen. Nobody posts the boring, sad or pesky moments of his or her life. Everybody sees the flawless self-drawn picture of you and subconsciously compares that picture to his or her own actual life. Granted, such comparison often depresses. Admit it.

Syma X5C Review

I was curious about drones all along. Indisputably, drones are compelling to every nerd’s heart but they were always somewhat expensive and I lacked use for one. Fortunately, the topic of my Master’s thesis involves drones too, so I found a convenient excuse to buy a drone ‘for practice and research’.

Syma X5C during indoor flightNote: Simultaneously flying a drone and capturing a photo of it requires skill


The Syma X5C Explorer is fairly cheap and was recommended to me as a rather good choice for beginners so I bought it. The drone also features a small HD camera1 and is suitable for indoor and outdoor flights.

After a couple of flights indoors I can confirm that this is an excellent drone for beginners and operating the drone is pure fun! A big bummer though is battery life. You get two 500mAh batteries and each lasts for about 7-10 minutes after a full charge (45-60 minutes of charging). This is not a lot, especially because time flies (pun intended) while operating the drone. It more feels like 5 minutes of flight time per battery. I recommend getting at least 1-2 extra batteries.

The remote control and the drone itself feels cheap but I guess you can’t expect anything fancy for under 100€. The remote control allows you to activate the camera and switch between HIGH and LOW, the two flight modes of the drone. The drone is noticeably faster in HIGH mode so I recommend to stay in LOW during indoor flights.

The camera records pictures and videos on a 4GB SD card (included) but the results are very disappointing. For some fun shots it’s enough I’d say but nothing more.

One of the coolest features is the looping function. When pushing a button on the remote control plus tilting the Syma, the drone will perform a looping in that direction. This sounds easy but mastering a looping near to the ground requires a bit of skill and looks particularly awesome when landing the looping just above the ground without crashing. It’s so much fun.

All in all I recommend the Syma to almost everybody who is fascinated about gadgets, tech or toys. Just please get some extra batteries!


  1. Well, it’s 1,2 megapixels and records 720p video. You can call that ‘HD’ or not

My AeroPress method

I’ve spent the last two weeks trying to find the best method to brew coffee with my newly acquired AeroPress. This is the moment I feel confident enough to share the method that works best for me - at least for now.

My coffeetable equipment

Coffee

This is the part I am probably least interested in. I usually buy some sort of Lavazza beans. Use your coffee of choice as long as you use beans and grind them by yourself.

Grinding

Some people think that electric coffee grinders destroy some taste because the resulting heat of the spinning blades ‘kills’ flavours. I don’t really care. I bought this one from Russel Hobbs and so far I have no complaints except that the least amount of coffee you can grind is for two cups. This isn’t really an issue because I like my coffee a bit stronger anyway.

Standard or inverted?

Inverted for sure. It doesn’t feel right to let juice dripping through the filter even before pushing down the plumber so I quickly decided to adopt the inverted AeroPress method for all of my brewing.

Here are the steps of brewing my favorite coffee:

  1. Boil some water and let it sit in the boiler to let it cool down a bit (1-2 minutes at least)
  2. Prepare the AeroPress inverted-style
  3. Grind the coffee and put between 1-2 AeroPress spoons in. I use a very fine grind and the amount of coffee that the Russel Hobbs grinder supposes for 2 cups.
  4. Pour some water in until everything is submerged under water.
  5. Stir for about 20 seconds
  6. Pour water until almost the entire AeroPress is full
  7. I don’t wash out the paper filter. Just place it in the cap and put it on.
  8. Let everything sit for about 60 seconds.
  9. Flip and press down the plumber. I think it really doesn’t matter how fast or hard, just don’t press too hard.
  10. Don’t add anything to it! Drink it black.

I keep expermienting until I am completely satisfied. But this is very close to my personally perfect coffee. Enjoy.

Peek and Pop - a minimal example

Implementing Peek and Pop for 3D Touch programmatically on iPhone 6S for TableView Data is easy when following these simple steps:

1. Extend your TableViewController with UIViewControllerPreviewingDelegate

class ExampleTableViewController: UITableViewController, UIViewControllerPreviewingDelegate {
	...
}

2. Register 3D Touch Controls in viewDidLoad

override func viewDidLoad() {
        super.viewDidLoad()
        registerForPreviewingWithDelegate(self, sourceView: view)
		...
}

3. Implement Peek and Pop behaviour in protocol functions as such:

Note that you have to set a storyboard id for your destination ViewController in your Main.storyboard (here: ExampleDetailViewController)

func previewingContext(previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {
        let indexPath = tableView.indexPathForRowAtPoint(location)
        let row = indexPath?.row

	let detailVC = storyboard?.instantiateViewControllerWithIdentifier("DetailViewController") as? ExampleDetailViewController
		
        // pass your object for selected row 
        //detailVC?.passedObject = ...
        
	// change dimensions as you please
	detailVC?.preferredContentSize = CGSize(width: 0, height: 380)
        
        return detailVC
    }
    
func previewingContext(previewingContext: UIViewControllerPreviewing, commitViewController viewControllerToCommit: UIViewController) {
        showViewController(viewControllerToCommit, sender: self)
}

Enjoy :)

I jumped off a plane wearing an Apple Watch

Today was an exciting day. My heartbeat proves it.

tandem-fly

I jumped off a plane (3000 meters height), had a free fall for about 1500 meters and then parachuted down the rest. All this happened in approximately 2-3 minutes. I tracked my heart rate during all of this by wearing an Apple Watch during flight and fall.

tandem gif

As for “Parachuting” not being on the list in the Workout app, I chose “Other” from the list. ;) As you can see, my heart-beat was surprisingly calm right before the jump (~50 BPM at 9:39 A.M.) and jumped (hah!) to round about 144 BPM in free-fall. I expected it to be much higher.

tandem heartbeat 1tandem heartbeat 1


What You think I need

It happened, I bought it, I don’t regret it: Apple Watch

In this post I don’t want to talk about the watch itself, but would rather like to address something different: the social awareness of wearable tech.

So here’s what happened a dozen times when people noticed this piece of technology on my wrist: “Is this the Apple Watch? (…) but do you really need this?”

I can’t express how I feel about this question.

Back when smartphones weren’t a thing, the same people said all the same things: “Nah, I don’t need all these features. I need a cell phone to make and receive calls with. I can’t make use of this other stuff.” Five to six years later, every single person I know has some sort of smartphone in his pocket. Do they need one? In my opinion they still don’t. All I see is them using mobile messengers, scrolling through facebook or listening to music.

The thing is: You don’t NEED things. You don’t NEED a smartphone. You don’t NEED a TV either! And this means you surely don’t NEED an Apple Watch (or any mechanical watch for that matter). But why do I have one? Because I WANTED one and I could make thought of at least a handful of scenarios where one would make sense in my life.

Society isn’t ready for wearable tech. It wasn’t ready for touchscreen mobile phones in the past but it is now.

But please… don’t give me the look and tell me what you think I don’t need. Just don’t.

Switching to ZSH

I changed my default shell from bash to ZSH.

There was no particular reason, I was just bored and heard a lot of good things about it. So I gave it a shot and I was pretty underwhelmed at first because it behaves -in its base configuration- just like bash. Things changed rapidly when I discovered ohmyz.sh which is a supercharged framework for ZSH. If you spend a lot of your time in a terminal, check it out.

It features support for:

  • themes
  • plugins (e.g. handy aliases, auto-completions, etc.)
  • interactive scripts (e.g. PROMPT appearance)
  • and more

zsh example

I am not a fan of using someone else’s configuration1 but oh-my-zsh has a very neat default configuration with only one plugin (git) activated and teaches you to manage your .zshrc file yourself.

Tipp: After installing oh-my-zsh on your system, append the content of your .bash_profile to your .zshrc. By doing so, you won’t lose your custom PATH, aliases, etc.

cat ~/.bash_profile >> ~/.zshrc

  1. I strongly discourage you to adopt someone else’s configuration for VIM because those are usually cluttered with plugins and keybindings you won’t use and will most likely confuse you instead. I suggest you should grow your .vimrc yourself and add things over time.

Coq development in VIM

In the light of recent events, I needed a functional IDE for coq development. And because I don’t like CoqIDE for my personal needs (and further cosmetic reasons) I searched for a suitable alternative.

coquille is a plugin for the marvelous VIM text editor and works like a charm.

First, install coq (obviously). I suppose you have homebrew installed:

brew install coq

Then install the plugins (using pathogen.vim):

cd ~/.vim/bundle
git clone https://github.com/def-lkb/vimbufsync.git
git clone https://github.com/the-lambda-church/coquille.git

For handy key mappings, add the following to your .vimrc:

au FileType coq call coquille#FNMapping()

Finally, open a .v File and start coq with :CoqLaunch

Also, I defined two key mappings for launching and quitting coq:

map <F8> :CoqLaunch<CR>
map <F9> :CoqKill<CR>

For further documentation, take a look at the GitHub repository.

Enjoy.

coq-vim

Watch Out

The Apple Watch will go on sale April 24th, with prices starting at $349 and running to over $10,000 for its top-of-the-line models. Apple Watch Sport, the low-end model housed in aluminum, starts at $349 for the 38mm model and $399 for the 42mm model. The stainless steel Apple Watch will start at $549 for the 38mm model and $599 for the 42mm model, with prices ranging up to $1,049 and $1,099 depending on the band they’re paired with. The 18-karat gold Apple Watch Edition will start at $10,000.

The Verge

I’m out. Paying thousand dollars for a watch that I will probably have to replace every 2-3 years with a newer model isn’t quite my thing.

No thank you.

The Apple Watch I'm not buying

I don’t want an Apple Watch. That’s what I keep telling myself since its announcement.

Before I start babbling about my struggle, let me make something clear: I’m totally aware of wearing a piece of technology on my body. When the first Pebble came out, I channeled my inner geek and got one as soon as it was available in Germany. It was cutting-edge at the time (no pun intended) and I’m still wearing it every day. I exchanged the standard silicone strap for a leather one from Fossil to make it visually more appealing. It’s still a plastic watch but I like everything more with some leather attached to it:

pebble-leather-1pebble-leather-2


Today, I’m surprised how socially accepted these smart watches are. Every time someone notices my Pebble, they are strikingly aware of what it is and what it does. “Oh, so it shows notifications from your phone? Cool, my cousin also has one.” Even my technologically unenthused best friend has a Sony smart watch!

I noticed early: Smart watches seem to make you more social and I don’t mean this in a social-networky way! You spend more time actually paying attention to your real-life when you just take a glance at your wrist instead of pulling out your phone every time it buzzes. I can’t count the times I left my phone in my pocket, just because the notification wasn’t that important or could be handled later.

Let’s talk about the Apple Watch. It can do more, is more sexy and -most important- is more cutting-edge than my Pebble.

aw-black-stainless

Nevertheless, I don’t want to buy one. Considering that the model I would want (the one with a steel strap seen above, not the sports one) will propably cost around $5001 and the battery most likely won’t last for more than a day, I’m almost completely disillusioned.

For me, the Apple Watch does too much. I’m not interested in health- and fitness-tracking or sending stupid emoticons -or worse- my heartbeat to my friends.

But let’s be honest: I know myself quite well. Sooner or later, I’ll get one. Let alone the fact that I’m writing about something I’m not willing to buy kinda speeks for itself. Heck, I already decided which one to buy.


  1. Guess we’ll find out in the next days

[Workflow] Blogging with Jekyll

As you might already know, I use Jekyll for creating this site.

In the following I’ll explain what my regular publishing workflow looks like. If you’re not yet familiar with Jekyll, take a look at its documentation.

Disclaimer: Most people use Jekyll in combination with git. My workflow doesn’t require git at all. Please don’t yell at me how wrong I am about not using git for publishing. Why? I’ll explain at the end of this post.

When writing a new post, I constantly have a Terminal window open, running jekyll serve -w. This builds and runs the site locally, allowing me to check a preview of my site at http://127.0.0.1:4000/. The -w option watches for changes and rebuilds the site every time I save the .md file in my text editor.

After I’m finished writing the post and it’s ready to be published on the web, I use the builtin functionality of Unix: scp. Remember that all of the compiled site is located in the _site/ subdirectory.

jekyll build && scp -r _site/* markus@my.server.net:html/

For more convenience, I put a macro for this in my ~/.bash_profile:

_blogupdate()
{
        cd ~/blog
        jekyll build && scp -r _site/* markus@my.server.net:html/
}
alias blogupdate=_blogupdate

This allows me to quickly run blogupdate to upload changes to my website. I’m not a fan of committing every change to a git repository. Just imagine the number of commits for fixing typos or minor layout changes. Don’t get me wrong, I definitely recommend git for keeping track of major commits. It’s just that I prefer not to jam my repositories with ‘Fixed typo’ commits. Plus, I don’t have to mess with git hooks.

[Workflow] Presenting with reveal.js

Since I quit using third-party tools for almost every common task I’m handling, here’s my workflow for creating presentations.

reveal.js is a JavaScript framework for creating beautiful and responsive presentations using HTML. All you need is a text editor to edit the source and a modern web browser to view your presentation. Bye Powerpoint, bye Keynote. Plus, HTML presentations are portable, light and can be published easily.

Just download the source and you’re ready to go. Take a look at the documentation for some help.

For starters, edit only the index.html file of the source. Every <section>-tag inserts a new slide. Use basic HTML to structure your slide. For effects and transitions, take a look at the example index.html. In most cases, using the ‘fragment’ class is sufficient but there are plenty of options.

For a more personal touch, create your own theme! Doing so requires grunt installed on our machine. I suggest you create a copy from one of the templates located in css/theme/source/ and save it as a new .scss file. You then need to add your theme to the Gruntfile.js (alongside the other themes) in the root directory of your presentation and save it.

Run grunt sass:themes from the command line to add your theme to the framework. Then include your new theme to your index.html file for use:

<link rel="stylesheet" href="css/theme/myNewTheme.css" id="theme">

For viewing your presentation, just open the index.html file in your web browser. Pressing the ‘S’ key opens the speaker screen in a new window, ‘Esc’ shows an overview of your slides and the ‘F’ key takes your presentation fullscreen.

I you’re interested in using reveal.js yourself, feel free to take inspiration from my Swift presentation (source) featuring my own Swift theme.

Enjoy :)

Simplicity

It’s been a few months since I had a huge struggle with my productivity and related technology. I noticed I couldn’t get anything done quickly due to a massive abundance of software solutions. So much time was lost organizing ‘tasks’ or ‘projects’ in OmniFocus, ‘structuring thoughts’ in mind maps or deciding which fancy text editor works best for me1.

Since a few weeks I am adopting a new way: Keeping things simple. Purging my computer and phone from unnecessary and distractive software did help a lot, concidering I was forced to concentrate on fewer windows, applications and problems caused by them.

The Mac is my primary work machine and is used for programming, communicating, research and pretty much nothing else!

simpleDock From left to right: Finder, Safari, MailMate (mail client), TextMate (text editor), Messages, Terminal


Trust me, the apps you see in my dock are truly the only ones I use on a daily basis. When I visit my desk, there’s either some mail waiting to be processed or some programming / writing I need to do. All of that can be achieved by persistently using 3-4 apps at max.

There was a ruthless software expulsion going on, where I deleted the majority of third party software from my computer. Alfred, TextExpander and Dropbox2, etc. are great tools but I removed them and went back to either their built-in counterparts or stopped caring about their comfort. The only ‘big’ third party alternative I still use is MailMate because it’s ridiculously better than using Apple Mail.

With the functionality MacOS / UNIX provides itself, many of my most frequently executed tasks can be done in Terminal: Compiling programs with CLIs for compilers, posting to my blog via scp, monitoring system status via top or adding functionality with homebrew. I quit using GUI applications for those.

I get that it’s more like a personal thing and not the fault of third party software but it feels nice to stick with the basics and actually spending more time mastering ‘good apps’ than losing time fiddling with ‘better apps’. Let’s see whether this puristic approach is working better for me over time or not. As for now, it is.


  1. Don’t get me started on text editors

  2. Yes, I also stopped using Dropbox. Go ahead, call me a masochist

Safe use of optionals in Swift

Let’s have a quick look at optionals in Swift.

You might have noticed that almost every constructor of a NSObject returns an optional of that type.

Take NSString for instance:

stringContentsOfURL

NSString? means you get an object of type NSString depending on whether the constructor succeeded creating the object or not. It also means that you have to unwrap that value before use.

This can lead to various compiler problems and if you are not familiar with optional values in Swift, further unexpected problems may occur.

Let’s take a look at some code.

var optUrl = NSURL(string: "https://zoppelt.net/Zoppelt.asc")
var optStr = NSString(contentsOfURL: optUrl!, encoding: NSUTF8StringEncoding, error: nil)

println(optStr!)

Note that you need a ! appended to both variables before you can use them. If you don’t, Xcode yells an error at you:

optionalErrorFix

You may be tempted to hit Enter on that “Fix-it” but you really shouldn’t! Adding a ! forces an unwrap, so if your value is nil (you never know for sure) your application will crash.

Try it: Change the url to something broken (e.g. “httttttp://foo.net”) and you get a crash (duh). A very common error message after a crash: "[...] found nil while unwrapping an optional value [...]".

There’s a better way to do it:

if var optUrl = NSURL(string: "https://zoppelt.net/Zoppelt.asc")
{
    if var optStr = NSString(contentsOfURL: optUrl, encoding: NSUTF8StringEncoding, error: nil)
    {
        println(optStr)
    }
}

Here we make use of the conditional initialization. When using optUrl or optStr inside the curly braces of their conditional initialization, they are automatically unwrapped properly.

Plus: If the constructor of NSURL or NSString fails, nothing bad will happen.

iPad free

iPad Air 2 - I can’t describe how much I’m not wanting this.

Don’t get me wrong, I used to like my iPad 2 and 3 a while ago when I still had to read PDFs for university (or sometimes needed some distraction during lectures) but it doesn’t do the trick for me anymore.

Over the past year I had a single use case for my iPad: Watching Netflix in bed. Safe to say this use case was completely destroyed the moment I moved into my new home with a badass living room holding a 50” TV and a comfortable couch.

That was almost 4 months ago. I touched my iPad maybe 5 times since then. I simply don’t know what to do with it.

So from this moment, I try to live ‘iPad free’. (My iPad 3 is already on sale)

Every task I have to complete in my tech life does either require a text editor / IDE or a terminal.

Have a look at my “always active” apps in my Dock:

Apps in Dock

  • Safari (possible on an iPad)
  • MailMate (never used my iPad for writing mails)
  • TextMate (tried using Textastic for iPad, but meh)
  • Messages (iPhone does it)
  • Terminal (lol iPad)
  • Xcode (omg lol iPad)

Contact me on Twitter if you want to tell me how wrong (or right) I am getting rid of my iPad.

Stats for Killzone Shadow Fall 1.0 released

I hope everyone of you is enjoying iOS 8 (and maybe a new phone?)

Just in time, Apple approved my KZ:SF Stats app, polished for iOS 8.

App Store Button

Killzone Shadow Fall Stats is an iPhone app that lets you keep track of your KILLZONE SHADOW FALL game stats. No seperate login required. Just enter your PSN-ID and you’re good to go.

Manual:

  • Swipe left to view your clan stats and take a look at your clan members
  • Double tap anywhere to refresh
  • That’s it

Updates

Stay tuned for future updates:

  • View profiles of clan members
  • Compare stats to others
  • Support for clan matches

Quick look:

KZSF-1 KZSF-2

Homescreens September 2014

All those fancy people keep posting screenshots of their iPhone and iPad homescreens so here I go.

It’s almost two years since I decided to stick with only one homescreen and it was worth, trust me. I jam unimportant apps into folders and Spotlight will find them if necessary.

iPhone

Homescreen iPhone September 9th
  • Threema - Since I’m cowardly refusing to use WhatsApp, Threema got me covered for at least a handfull of non-apple friends.
  • Fantastical - I often switched calendar apps but I stopped looking after I realized how efficient Fantastical is in everyday calendar management. Give it a try.
  • OmniFocus - If you’re looking for a quick and dirty way for managing your tasks and projects, OmniFocus is not your first choice. But if you’re interested in some in-depth project planning and managing, you should use this app.
  • 1Password - Everyone should be using different passwords for different sites and accounts. I do, 1Passwords manages them.
  • Sonos - The Sonos app icon is propably the one I hit most often a day. My home is all set up with the sonos music system and I don’t regret a penny I spent for it.
  • Tweetbot - If you’re reading this blog you most likely use twitter. Of course you do. Tweetbot is my favorite app for reading all your interesting stuff you yell into the internet all day.
  • Overcast - One of my minor hobbies is to listen at podcasts when I’m at home or in the car. Overcast is a project by Marco Arment (you presumably knew him already).
  • Spotify - Music streaming killed local music files for me.

'’What’s inside the folder?’’ - Some crap you could care less about ;)

iPad

Homescreen iPad September 9th

You may recognize some apps from my iPhone screen. I won’t lose any more words about them.

  • Air Video HD - Air Video connects to a server software on your Mac or PC and plays video files or movies. I use it for downloaded TV shows and use AirPlay to watch them on my Apple TV.
  • YouTube - Google it
  • Status Board - Displays all sorts of data and can be used as kind of a blackboard with news or stats when connected to an Apple TV. Find out more
  • Netflix - Primary use case for my iPad. Lean back and burn away boring hours or even days with this video-on-demand service.

Some interesting apps in folders:

  • TV Forecast HD
  • Textastic - A code editor
  • Prompt - ssh client for connecting to remote servers or your own machines

-DISCLAIMER-

You might use your devices differently. That’s okay.

Using Swift Language in LaTeX

I was searching for an easy way for syntax highlighting of swift code in LaTeX generated PDFs. This is the easiest way I found:

1. Install Pygments (you’ll need Python)

Pygments is a generic syntax highlighter written in python that can be used standalone to highlight different programming languages (including swift!) and writes them to stdout. We’ll configure it to work hand-in-hand with your LaTeX distribution. You can install Pygments via pip. If you don’t have pip installed, install it first:

sudo easy_install pip

Then you can install Pygments:

sudo pip install Pygments

Make sure that the version you downloaded has already enabled swift support:

pygmentize -L | grep swift

You should see something like that:

MacBook-Pro:youreawesome markuszoppelt$ pygmentize -L | grep swift
* swift:
Swift (filenames *.swift)

(If nothing shows up, clone from the Pygments Repository and try building it yourself. That step should not be necessary :) )

2. Make sure you have the “texments” package installed

This is easy if you use the ‘Tech Live Utility’ on a Mac, just search for it:

Tex Live Pygmented

If you don’t use Tex Live Utility, you can build the .sty yourself from here.

3. Using swift syntax in LaTeX

After you set up everything correctly, you should be ready to go:

Minimal Example:

\documentclass[a4paper,DIV=calc]{scrartcl}

\usepackage{texments}
\usestyle{xcode}

% endpreamble

\begin{document}

\begin{pygmented}{swift}
//  NavigationController.swift

import UIKit

class NavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()
    
        // Navigation-Text
        navigationBar.tintColor = UIColor.whiteColor();
        navigationBar.alpha = 0.7;
    
        navigationBar.backgroundColor = UIColor.clearColor()
        navigationBar.barTintColor = UIColor.clearColor()
        navigationBar.barStyle = UIBarStyle.BlackTranslucent
    
        self.navigationBar.translucent = true
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}
\end{pygmented}

\end{document}

Note that you need to include the package ‘texments’ AND set a style (e.g. ‘xcode’) before starting to write code. Most often you need to insert big chunks of code in your document, so keep using the pygmented environment. Its only parameter is the language. The example above will create following PDF. Compile your document:

pdflatex --shell-escape document.tex

Have fun writing syntax highlighted swift code in LaTeX!

Impressum
© 2017 Markus Zoppelt.