macOS

    My daily driver is a MacBook Pro, this is the thing that I will run when I
    switch to a new computer.

    GUI environment

    The plist file for setting up PATH for GUI applications.
         <?xml version="1.0" encoding="UTF-8"?>
         <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
         <plist version="1.0">
           <dict>
             <key>Label</key>
             <string>x.env</string>
             <key>ProgramArguments</key>
             <array>
               <string>sh</string>
               <string>-c</string>
               <string>
                 launchctl setenv PATH $PATH:/usr/local/bin:/usr/local/sbin
               </string>
    
             </array>
             <key>RunAtLoad</key>
             <true/>
           </dict>
         </plist>

    setup homebrew

      which -s brew
      if [[ $? != 0 ]]; then
          echo "install homebrew"
          /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
      fi
      # brew tap Homebrew/bundle
      brew update
      brew bundle --file=.dist/Brewfile

    Brewfile

    Basic

    These are the must haves, for any Mac machine that I have to be working on.
      tap 'caskroom/cask'
      tap 'caskroom/fonts'
      tap 'railwaycat/emacsmacport'
      brew 'tree'
      brew 'git'
      brew 'git-flow-avh'
      brew 'hub'
      brew 'coreutils'
      brew 'fish'
      brew 'vim'
      brew 'emacs-plus'
      brew 'tmux'
      brew 'reattach-to-user-namespace'
      brew 'the_silver_searcher'
      brew 'aspell', args: ['with-lang-en']
    
      # casks
      cask 'google-chrome'
      cask '1password'
      cask 'istat-menus'
      cask 'bartender'
      cask 'slack'
      cask 'skype'
      cask 'font-hack-nerd-font'
      cask 'karabiner-elements'
      cask 'hammerspoon'

    Personal

    This list is for my personal computer.
      cask 'dropbox'
      cask 'omnigraffle'
      cask 'omnifocus'
      cask 'plex-media-server'

    The Tweaks

    iterm2

    Use zsh instead of bash. command+,= -> =Profiles -> Command. Set to /usr/local/bin/zsh. Enable system-wide hotkey. Enable =Meta= key for emacs.

    spell checking

    I choose not to tangle dictionary files because I want to use symbol links, for easy save new words.
      for file in "$(pwd -P)"/resources/*; do
          target="${ZDOTDIR:-$HOME}/.$(basename $file)"
          if [[ -h "$target" || -a "$target" ]]; then
              rm "$target"
          fi
          ln -s "$file" "$target"
      done

    fix ssh

    This is for fixing ssh keys in macOS Sierra. Following this article.
      Host *
        AddKeysToAgent yes
        UseKeychain yes
        IdentityFile ~/.ssh/id_rsa

    Terminal.app color theme

    I am currently a fan of dradula theme.

    Hammerspoon

    link the whole folder

    Hyper Key

    -- A global variable for the Hyper Mode
    hyper = hs.hotkey.modal.new({}, 'F17')
    hs.window.animationDuration = 0 -- disable animations
    
    -- Enter Hyper Mode when F18 (Hyper/Capslock) is pressed
    function enterHyperMode()
      hyper.triggered = false
      hyper:enter()
    end
    
    -- Leave Hyper Mode when F18 (Hyper/Capslock) is pressed,
    -- send ESCAPE if no other keys are pressed.
    function exitHyperMode()
      hyper:exit()
      if not hyper.triggered then
        hs.eventtap.keyStroke({}, 'ESCAPE')
      end
    end
    
    -- Bind the Hyper key
    f18 = hs.hotkey.bind({}, 'F18', enterHyperMode, exitHyperMode)

    Window Management

    Toggle full screen mode with hyper + Enter.
    hyper:bind({}, "return", function()
        local win = hs.window.frontmostWindow()
        win:setFullscreen(not win:isFullscreen())
        hyper.triggered = true
    end)
    Some config.
    local ratio = 3
    Move current window to 1/3 on the left.
    hyper:bind({}, "Left", function()
        local win = hs.window.focusedWindow()
        local f = win:frame()
        local screen = win:screen()
        local max = screen:frame()
        local width = math.max(600, max.w / ratio)
        f.x = max.x
        f.y = max.y
        f.w = width
        f.h = max.h
        win:setFrame(f)
    end)
    Move current window to 1/3 on the right.
    hyper:bind({}, "Right", function()
        local win = hs.window.focusedWindow()
        local f = win:frame()
        local screen = win:screen()
        local max = screen:frame()
        local width = math.max(600, max.w / ratio)
        f.x = max.w - width
        f.y = max.y
        f.w = width
        f.h = max.h
        win:setFrame(f)
    end)

    Shortcuts

    Terminal.
    hyper:bind({}, "t", function()
        hs.application.launchOrFocus("iTerm")
    end)
    hyper:bind({}, "e", function()
        hs.application.launchOrFocus("Emacs")
    end)

    Init

    require "hyper"
    require "window"
    require "shortcuts"
    
    -----------------------------------------------
    -- Reload config on write
    -----------------------------------------------
    function reload_config(files)
      hs.reload()
    end
    
    hyper:bind({}, "r", function()
      reload_config()
      hyper.triggered = true
    end)
    
    hs.pathwatcher.new(os.getenv("HOME") .. "/.hammerspoon/", reload_config):start()
    hs.alert.show("Config loaded")