{"id":2069,"date":"2016-03-13T13:41:23","date_gmt":"2016-03-13T12:41:23","guid":{"rendered":"https:\/\/denbeke.be\/blog\/?p=2069"},"modified":"2016-10-16T18:47:18","modified_gmt":"2016-10-16T17:47:18","slug":"getting-a-mac-ready-for-development","status":"publish","type":"post","link":"https:\/\/denbeke.be\/blog\/mac\/getting-a-mac-ready-for-development\/","title":{"rendered":"Getting a Mac ready for development"},"content":{"rendered":"<p>Apple computers are awesome: they are fancy machines which make your daily life easier. But every developer knows that there are a lot of things to install and configure before you can actually start programming. This guide is an overview of how I configure my Mac for development. I&#8217;m sure everyone has his own habits regarding tools and configurations, but this guide should get you started!<\/p>\n<p><em>Note: I wrote this guide while configuring my Mac running El Capitan (OS X 10.11). Things might (and probably will) change for future OS X versions.<\/em><\/p>\n<h3 id=\"command-line-tools\">Command line tools<\/h3>\n<h4 id=\"fish-shell\">Fish shell<\/h4>\n<p>Fish is <em>&#8220;a smart and user-friendly command line shell for OS X, Linux, and the rest of the family.&#8221;<\/em> It makes your life in the terminal a lot easier: it comes with autosuggestions, man page completion, nice colours, web-based configuration, and a clean and simple scripting language.<\/p>\n<p>Download <a href=\"https:\/\/fishshell.com\" target=\"_blank\">Fish<\/a> from their website and run the installer. After the installation you must manually set the shell as your default shell:<\/p>\n<pre><code>$ chsh -s \/usr\/local\/bin\/fish<\/code><\/pre>\n<h4 id=\"fish-functions\">Fish functions<\/h4>\n<p>You can easily create your own function with Fish. To do so, you must create a file with the function name in the <code>~\/.config\/fish\/functions<\/code> directory.<\/p>\n<h5 id=\"fish-prompt\">Fish prompt<\/h5>\n<p>The prompt is a Fish function itself, which you can fully customize. Here is the prompt I use for Fish (<code>~\/.config\/fish\/functions\/fish_prompt.fish<\/code>):<\/p>\n<pre><code>function fish_prompt --description 'Write out the prompt'\r\n\r\n    set -l last_status $status\r\n    \r\n    if not set -q __fish_prompt_normal\r\n        set -g __fish_prompt_normal (set_color normal)\r\n    end\r\n    \r\n    # PWD\r\n    set_color $fish_color_cwd\r\n    echo -n (prompt_pwd)\r\n    set_color normal\r\n    \r\n    printf '%s ' (__fish_git_prompt)\r\n    \r\n    if not test $last_status -eq 0\r\n        set_color $fish_color_error\r\n    end\r\n    \r\n    echo -n '$ '\r\n\r\nend<\/code><\/pre>\n<h5 id=\"opening-files-with-chocolat-editor\">Opening files with Chocolat editor<\/h5>\n<p>I have a Fish function which opens a given folder or file with my favorite editor (Chocolat, see below). Put this function in <code>~\/.config\/fish\/functions\/chocolat.fish<\/code>:<\/p>\n<pre><code>function chocolat\r\n    if test -z \"$argv\"\r\n        open . -a Chocolat\r\n    else\r\n        open $argv -a Chocolat\r\n    end \r\nend<\/code><\/pre>\n<h5 id=\"sudo\"><code>sudo !!<\/code><\/h5>\n<p>Fish has no <code>sudo !!<\/code> command. If you really need it, you can create your own (<code>~\/.config\/fish\/functions\/sudo.fish<\/code>):<\/p>\n<pre><code>function sudo\r\n    if test \"$argv\" = !!\r\n        eval command sudo $history[1]\r\n    else\r\n        command sudo $argv\r\n    end\r\nend<\/code><\/pre>\n<h4 id=\"xcode\">Xcode<\/h4>\n<p>First you need to install Xcode from the Mac App Store. Once installed, you also need the <em>Command Line Tools<\/em>, you can initiate the download process by executing <code>$ xcode-select --install<\/code> in the Terminal.<\/p>\n<h4 id=\"vim\">Vim<\/h4>\n<p>Vim is my favorite editor in the console. No need to install it because it&#8217;s part of the command line tools. You can completely customize it: I have the following Vim config in <code>~\/.vimrc<\/code>:<\/p>\n<pre><code>\" Vim config\r\n\r\nset number                      \"Line numbers are good\r\nset backspace=indent,eol,start  \"Allow backspace in insert mode\r\nset showcmd                     \"Show incomplete cmds down the bottom\r\nset showmode                    \"Show current mode down the bottom\r\nset gcr=a:blinkon0              \"Disable cursor blink\r\nset visualbell                  \"No sounds\r\n\r\n\" enable syntax highlighting\r\nsyntax on   \r\n\r\n\" indentation\r\nset autoindent\r\nset smartindent\r\nset smarttab\r\nset shiftwidth=4\r\nset softtabstop=4\r\nset tabstop=4\r\nset expandtab<\/code><\/pre>\n<h4 id=\"macports\">MacPorts<\/h4>\n<p>MacPorts is a package manager for OS X, which is quite similar to FreeBSD Ports. <em>Yeah, I know, some people prefer <a href=\"http:\/\/brew.sh\" target=\"_blank\">Homebrew<\/a>&#8230;<\/em><br \/>\nDownload the <a href=\"https:\/\/www.macports.org\" target=\"_blank\">MacPorts<\/a> installer from their website (make sure to download it for the correct operating system) and install MacPorts.<\/p>\n<p>If you are using Fish (MacPorts does it automatically if you use Bash, which is the default one on OS X), you must manually set your <code>PATH<\/code> correctly. Add the following line to <code>~\/.config\/fish\/config.fish<\/code>:<\/p>\n<pre><code>$ set -xg PATH \/opt\/local\/bin \/opt\/local\/sbin $PATH<\/code><\/pre>\n<p>After installing MacPorts it&#8217;s good practice to update MacPorts and the ports tree:<\/p>\n<pre><code>$ sudo port selfupdate<\/code><\/pre>\n<h4 id=\"git\">Git<\/h4>\n<p>Git comes together with the Xcode command line tools.<br \/>\nMake sure to correctly setup your Git config, since your username and email will appear in every commit you author.<\/p>\n<pre><code>$ git config --global user.name \"Some username\"\r\n$ git config --global user.email some_mail@example.com<\/code><\/pre>\n<h4 id=\"go\">Go<\/h4>\n<p>Since I&#8217;m a <a href=\"https:\/\/golang.org\/\" target=\"_blank\">Go<\/a> developer, installing Go is one of the first things I do on a new Mac. Installing Go can be done very easily using MacPorts:<\/p>\n<pre><code>$ sudo port install go<\/code><\/pre>\n<p>You must also define your Go path. More info about how the <code>$GOPATH<\/code> should look like can be found <a href=\"https:\/\/golang.org\/doc\/code.html\" target=\"_blank\">here<\/a>.<br \/>\nUsing Fish shell, you must add it to <code>~\/.config\/fish\/config.fish<\/code>:<\/p>\n<pre><code>set -xg GOPATH ~\/Code\/Go\/<\/code><\/pre>\n<p>Using Bash:<\/p>\n<pre><code>$ export GOPATH=~\/Code\/Go\/<\/code><\/pre>\n<p>To make this permanent (for Bash) you must put the command in your <code>.bash_profile<\/code>.<\/p>\n<p>Optionally you also add your Go bin folder to your <code>$PATH<\/code>. For Fish, you must again put it in <code>~\/.config\/fish\/config.fish<\/code>:<\/p>\n<pre><code>$ set -xg PATH $GOPATH\/bin $PATH<\/code><\/pre>\n<h4 id=\"c\">C++<\/h4>\n<p>Xcode comes with Clang compiler by default. If you need Gcc, you must install it using MacPorts:<\/p>\n<pre><code>$ sudo port install gcc5<\/code><\/pre>\n<p>Now you need to enable the MacPorts Gcc version, so you actually use it when executing the <code>gcc<\/code> command. (Apple linked the Gcc command to Clang&#8230;):<\/p>\n<pre><code>$ port select --list gcc\r\nAvailable versions for gcc:\r\n    mp-gcc5\r\n    none (active)\r\n\r\n$ sudo port select --set gcc mp-gcc5<\/code><\/pre>\n<p>You can verify your installation in the Terminal: <code>$ gcc -v<\/code><\/p>\n<h4 id=\"python\">Python<\/h4>\n<p>Python 2.7 comes bundled with the OS X command line tools. If you need a newer version of Python, you can install it using MacPorts:<\/p>\n<pre><code>$ sudo port install python35<\/code><\/pre>\n<p>You can also install pip, an awesome tool for installing extra Python packages\/modules:<\/p>\n<pre><code>$ sudo easy_install pip<\/code><\/pre>\n<h4 id=\"mamp-mac-os-x-apache-mariadb-php\">MAMP (Mac OS X Apache MariaDB PHP)<\/h4>\n<p>Doing web development? Then you probably want to install MAMP. See <a href=\"https:\/\/denbeke.be\/blog\/webdevelopment\/installing-mamp-mac-os-x-apache-mariadb-php-using-macports\/\" target=\"_blank\">this blogpost<\/a> for detailed instructions.<\/p>\n<p>You know <a href=\"https:\/\/caddyserver.com\" target=\"_blank\">Caddy<\/a>? Probably not, but it&#8217;s surely worth checking out! It&#8217;s a very easy and simple webserver which works perfectly with PHP-FPM.<\/p>\n<h4 id=\"other-ports\">Other ports<\/h4>\n<p>Install some other useful ports you might need:<\/p>\n<pre><code>$ sudo port install cmake wget pandoc mtr sl boost qt5 nodejs<\/code><\/pre>\n<h4 id=\"composer\">Composer<\/h4>\n<p>Install <a href=\"https:\/\/getcomposer.org\" target=\"_blank\">Composer<\/a>, the PHP package manager:<\/p>\n<pre><code>$ curl -sS https:\/\/getcomposer.org\/installer | php\r\n$ sudo mv composer.phar \/usr\/local\/bin\/composer<\/code><\/pre>\n<h4 id=\"sass\">Sass<\/h4>\n<p>Install the <a href=\"http:\/\/sass-lang.com\" target=\"_blank\">Sass<\/a> tool for preprocessing CSS stylesheets:<\/p>\n<pre><code>$ sudo gem install sass<\/code><\/pre>\n<h4 id=\"latex\">LaTeX<\/h4>\n<p>You can download and install a complete LaTeX bundle called <a href=\"http:\/\/tug.org\/mactex\/\" target=\"_blank\">MacTex<\/a>. It comes with a <code>.pkg<\/code> installer and doesn&#8217;t require any additional configuration.<\/p>\n<h3 id=\"software\">Software<\/h3>\n<p>This is a list of software I use (or just know). The tools listed here are worth checking out and are surely not new for most Mac users.<\/p>\n<h4 id=\"editors\">Editors<\/h4>\n<p>There are a lot of good code editors available for Mac. My personal favorite is Chocolat. Here is an overview of some good editors for OS X:<\/p>\n<p>General programming:<\/p>\n<ul>\n<li><a href=\"https:\/\/chocolatapp.com\" target=\"_blank\">Chocolat<\/a> (paid)<\/li>\n<li><a href=\"https:\/\/atom.io\" target=\"_blank\">Atom<\/a><\/li>\n<li><a href=\"https:\/\/www.sublimetext.com\" target=\"_blank\">Sublime<\/a> (paid)<\/li>\n<li><a href=\"https:\/\/itunes.apple.com\/be\/app\/textwrangler\/id404010395?mt=12\" target=\"_blank\">TextWrangler<\/a><\/li>\n<li>(<a href=\"http:\/\/www.barebones.com\/products\/bbedit\/\" target=\"_blank\">BBEdit<\/a>)<\/li>\n<li>Vim<\/li>\n<\/ul>\n<p>Web development:<\/p>\n<ul>\n<li><a href=\"http:\/\/macrabbit.com\/espresso\/\" target=\"_blank\">Espresso<\/a> (paid)<\/li>\n<li><a href=\"https:\/\/panic.com\/coda\/\" target=\"_blank\">Coda<\/a> (paid)<\/li>\n<li><a href=\"http:\/\/brackets.io\" target=\"_blank\">Brackets<\/a><\/li>\n<\/ul>\n<p>IDEs:<\/p>\n<ul>\n<li>Xcode<\/li>\n<li><a href=\"http:\/\/eclipse.org\" target=\"_blank\">Eclipse<\/a><\/li>\n<li><a href=\"https:\/\/www.jetbrains.com\" target=\"_blank\">Jetbrains<\/a> (paid, free for students)<\/li>\n<\/ul>\n<p>LaTeX editor: <a href=\"https:\/\/www.texpadapp.com\/osx\" target=\"_blank\">Texpad<\/a> (paid)<\/p>\n<h4 id=\"utilities\">Utilities<\/h4>\n<p>Some other useful apps for developers.<br \/>\nFTP:<\/p>\n<ul>\n<li><a href=\"https:\/\/cyberduck.io\" target=\"_blank\">Cyberduck<\/a><\/li>\n<li><a href=\"http:\/\/www.panic.com\/transmit\/\" target=\"_blank\">Transmit<\/a> (paid)<\/li>\n<li><a href=\"http:\/\/www.binarynights.com\/forklift\/\" target=\"_blank\">Forklift<\/a> (paid)<\/li>\n<\/ul>\n<p>Although I think you shouldn&#8217;t use a visual Git client and stick to the command line, there are some good Git clients for OS X:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.sourcetreeapp.com\" target=\"_blank\">SourceTree<\/a><\/li>\n<li><a href=\"https:\/\/www.git-tower.com\" target=\"_blank\">Tower<\/a> (paid)<\/li>\n<\/ul>\n<p>Others:<\/p>\n<ul>\n<li><a href=\"https:\/\/itunes.apple.com\/app\/the-unarchiver\/id425424353?mt=12&amp;ls=1\" target=\"_blank\">The Unarchiver<\/a> is there to help you unpack basically any archive.<\/li>\n<li><a href=\"http:\/\/www.iterm2.com\/#\/section\/home\" target=\"_blank\">iTerm2<\/a> Terminal alternative<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Apple computers are awesome: they are fancy machines which make your daily life easier. But every developer knows that there are a lot of things to install and configure before you can actually start programming. This guide is an overview of how I configure my Mac for development. I&#8217;m sure everyone has his own habits [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[114,235,161],"tags":[232,229,125,251,149,215,266,123,202,258],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v15.6.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Getting a Mac ready for development &ndash; DenBeke<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/denbeke.be\/blog\/mac\/getting-a-mac-ready-for-development\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Getting a Mac ready for development &ndash; DenBeke\" \/>\n<meta property=\"og:description\" content=\"Apple computers are awesome: they are fancy machines which make your daily life easier. But every developer knows that there are a lot of things to install and configure before you can actually start programming. This guide is an overview of how I configure my Mac for development. I&#8217;m sure everyone has his own habits [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/denbeke.be\/blog\/mac\/getting-a-mac-ready-for-development\/\" \/>\n<meta property=\"og:site_name\" content=\"DenBeke\" \/>\n<meta property=\"article:published_time\" content=\"2016-03-13T12:41:23+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-10-16T17:47:18+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary\" \/>\n<meta name=\"twitter:creator\" content=\"@MthsBk\" \/>\n<meta name=\"twitter:site\" content=\"@MthsBk\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data1\" content=\"6 minutes\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/denbeke.be\/blog\/#website\",\"url\":\"https:\/\/denbeke.be\/blog\/\",\"name\":\"DenBeke\",\"description\":\"Mathias Beke\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/denbeke.be\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/denbeke.be\/blog\/mac\/getting-a-mac-ready-for-development\/#webpage\",\"url\":\"https:\/\/denbeke.be\/blog\/mac\/getting-a-mac-ready-for-development\/\",\"name\":\"Getting a Mac ready for development &ndash; DenBeke\",\"isPartOf\":{\"@id\":\"https:\/\/denbeke.be\/blog\/#website\"},\"datePublished\":\"2016-03-13T12:41:23+00:00\",\"dateModified\":\"2016-10-16T17:47:18+00:00\",\"author\":{\"@id\":\"https:\/\/denbeke.be\/blog\/#\/schema\/person\/386878f712fe3fe22227216f087772dc\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/denbeke.be\/blog\/mac\/getting-a-mac-ready-for-development\/\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/denbeke.be\/blog\/#\/schema\/person\/386878f712fe3fe22227216f087772dc\",\"name\":\"Mathias Beke\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/denbeke.be\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/015ba35e6ce4f5859e3888ca99807575?s=96&d=mm&r=g\",\"caption\":\"Mathias Beke\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/posts\/2069"}],"collection":[{"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/comments?post=2069"}],"version-history":[{"count":3,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/posts\/2069\/revisions"}],"predecessor-version":[{"id":2134,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/posts\/2069\/revisions\/2134"}],"wp:attachment":[{"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/media?parent=2069"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/categories?post=2069"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/tags?post=2069"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}