Work More Efficiently On Mac

Managing Dotfiles In Org-Babel

I used to have almost 80% configurations that I stole from other people on the internet which are never used. Why? Maybe because I did not think why I need them, those things just did not be adopted in my daily workflow.

org-babel is a way that you can embed your code block in your literature. I've ever seen people use it to manage their Emacs configuration many times, and think it might be easy to manage my dotfiles also.

so, here you are, this is a post remains me why I need to have these configurations, how can I be more productivity, but it is also used to export all my configurations on mac.

Get The Missing Package Manager

Do you miss aplt-get, or any package manager on Linux after you switched to Mac? If you do then HomeBrew and HomeBrew Cask is what you are looking for.

Get Brew

ruby -e "$(curl -fsSL"

Add more sources

  • System duplicate formulae
brew tap homebrew/dupes
  • Versioned formulae
brew tap homebrew/versions
  • Homebrew Cask is an extension for Homebrew that allows you to automate the installation of Mac Apps.
brew tap caskroom/cask
  • Cask can also be used to automatically download and install fonts.
brew tap caskroom/fonts

Update formulaes

brew update

Use Spacemacs

Get Emacs

Can not use org-babel without Emacs. I use spacemacs because the default configuration really saves my time.

brew tap d12frosted/emacs-plus
brew install emacs-plus --HEAD --with-natural-title-bars
brew linkapps emacs-plus

Download spaceemacs cofiguration

git clone ~/.emacs.d

Better Terminal

Iterm2 has a lot useful features, such as split panes, hotkey window.


brew cask install iterm2

Enable Hotkey Window

Register a hotkey that brings iTerm2 to the foreground when you're in another application. A terminal is always a keypress away. This gives you an always-available terminal (like Visor, Guake, or Yakuake) at your fingertips.

  1. Creates a new profile named as Hotkey Window.
  2. Open Preference > Keys.
  3. Enable Show/hide iTerm2 with a system-wide hotkey, change Hotkey to Command + ;.
  4. Enable Hotkey toogles a dedicated window with profile, change the profile to Hotkey Window.

Better Keyboard Configuration

I am a fan of Emacs but prefer VIM style editing (which leads me to start using spacemacs), Capslock is useless and I never use it. Luckly, it seems a good place to put Ctrl/Escape there.

Remaps Capslock To Ctrl

  1. Go into the Keyboard preference pane.
  2. Click "Modifier Keys…", and change Caps Lock to Control.
  3. Download the lastest version of Seli.
  4. Open Seli and go other keys section to Change Ctrl_L

Remaps Capslock to Escape

  1. Download the lastest version of Karabiner.
  2. go into Karabiner and search for this option:
Control_L to Control_L
      (+ when you type Control_L only, send Escape)

Remaps Ctrl-L to Hypher

To define Hyper as control+option+command+shift.

  • Open Karabiner and go to Misc & Uninstall > Open private.xml).
  • Add this XML snippet directly under the element.
<?xml version="1.0"?>
    <name>Remap Left Control to Hyper</name>
    <appendix>OS X doesn't have a Hyper. This maps Left Control to Control + Shift + Option + Command.</appendix>



        ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L
  • Save the file, then open Karabiner and press ReloadXML in the upper-right of the Change Key tab.
  • Search for Remap Caps and check the box.

Don't sleep automatically

I truly don't understand why we need to install a third party application to do this... anyway, caffeine is your best friend, no mattter it exists in realiality or just in Mac.

The subtle Caffeine menu bar item is built for one thing in specific: keeping your Mac from going to sleep.

brew cask install caffeine

Uninstall application clearly

Again, I still don't understand why we need to install a third party application to do this.

brew cask install appcleaner

Use Zsh

I moved to zsh from bash a while. oh-my-zsh is the first framwork I used. It is handy and well documented but has slow startup times, Antigen is slow too. finally, I tried zplug and very happy with its speed and flexibility.


brew install zsh
git clone ~/.zplug
chsh -s /usr/local/bin/zsh


source ~/.zplug/zplug

Command Search PATH

export PATH=${HOME}/bin:${HOME}/.local/bin:/usr/local/bin:${PATH}

Default Editor

export EDITOR=vim

VIM mode

zplug "plugins/vi-mode", from:oh-my-zsh


zplug "themes/pygmalion", from:oh-my-zsh

Syntax Highlight

zplug "zsh-users/zsh-syntax-highlighting", nice:10

Type in any part of any previously entered command and press the UP and DOWN arrow keys to cycle through the matching commands. You can also use K and J in VI mode or ^P and ^N in EMACS mode for the same.

zplug "zsh-users/zsh-history-substring-search"

Bind UP and DOWN arrow keys

zmodload zsh/terminfo
bindkey "$terminfo[kcuu1]" history-substring-search-up
bindkey "$terminfo[kcud1]" history-substring-search-down

Bind P and N for EMACS mode

bindkey -M emacs '^P' history-substring-search-up
bindkey -M emacs '^N' history-substring-search-down

Bind k and j for VI mode

bindkey -M vicmd 'k' history-substring-search-up

Git Support

zplug "plugins/git", from:oh-my-zsh

OSX Enhancement

brew auto completion.

zplug "plugins/brew", from:oh-my-zsh

NodeJS Development Env

NPM auto completion

zplug "plugins/npm", from:oh-my-zsh

NVM setup

export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/

Install plugins automatically

zplug check return true if all plugins are installed Therefore, when it returns not true (thus false), run zplug install

if ! zplug check; then
    zplug install

Loads Zplug Plugins.

zplug load --verbose

Aliases & Additonal Commands

List all branchs in tig by default.

which tig >/dev/null     && alias tig=tig --all

Searches files with names containing a string

f: searches the current directory subtree for files with names containing a string (ignoring case). f png would find all PNG files in the current subtree, as well as “PNGisMyFavorite.txt” and so forth.

function f() { find . -iname "*$1*" ${@:2} }

Greps the current directory subtree for files matching a pattern.

r: recursively greps the current directory subtree for files matching a pattern. r HTTP would grep for files containing that exact string, while r '"http[^"]*"' -i would search for double-quoted strings starting with “http”, ignoring case.

function r() { grep "$1" ${@:2} -R . }


Normally I use Emacs to write codes and documents, but sometimes I do quick modification on terminal by using VIM.

Syntax Highlight

syntax on

Highlight and strip eatra white spaces

Highlight existing trailing whitespace and also strip trailing whitespace.

highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()

Use Git


Git is a widely used source code management system. When I start to develop something, my workflow always looks like:

  1. run git fetch, git rebase to get other people's changes.
  2. do some experimients.
  3. run git save to save current codebase, so I can go back if I screw up my code later.
  4. do some experimients.
  5. run git wipe if I don't like the result and want to throw current modifications to the hell.
  6. do some experimients.
  7. run git save.
  8. do some experimients.
  9. run git undo, if I want to commit some changes.
  10. run git save.
  11. run git r to re-organize my commit logs.
  12. run git push to deliver my works or save on cloud.


Get Git

brew install git

Get Tig

Tig is an ncurses-based text-mode interface for git. It functions mainly as a Git repository browser, but can also assist in staging changes for commit at chunk level and act as a pager for output from various Git commands.

brew install tig

Global Config

Set up my name and e-mail address

both of which are included in every commit i make.

  name = 陳信屹
  email =

Caching password in git

Cloning Github repositories using HTTPS is better than using SSH when you want to access those repositories in multiple deivces. The only annoy thing is you need to type password everytime and this caches your GitHub password in Git.

  helper = osxkeychain

Change git push behavior to simple

When pushing without giving a refspec, push the current branch to its remote branch.

  default = simple

Disable advices which isnt useful anymore

    It was useful when i was a beginer, but now it is annoy to me as a 老手!
  • Disable the advice shown by Git when you attempt to push something that’s not fast forward-able
  • Disable “how to stage/unstage/add” hints given by git status.
  pushNonFastForward = false
  statusHints = false

Useful Aliases

This saves a lot time, and I think you should do too!.

Alias Description
s View the current working tree status using the short format with branch information.
l View abbreviated SHA, description, and history graph of the latest 50 commits
c Clone a repository including all submodules
ci Normal git commit
ca Commit all changes
co Normal git checkout
p git push
save Adds all changes including untracked files and creates a commit as a savepoint.
undo Resets the previous commit, but keeps all the changes from that commit in the working directory
wipe Commit everything and then do hard reset.
r rebase lastest 15 commits
fc Find commits by source coude
fm Find commits by commit message
contributors List contributors with number of commits
  s = status -sb
  l = log --pretty=oneline -n 50 --graph --abbrev-commit
  c = clone --recursive
  ci = commit
  ca = !git add -A && git commit -av
  co = checkout
  p = push
  save = !git add -A && git commit -v -m 'SAVEPOINT'
	undo = reset HEAD~1 --mixed
	wipe = !git add -A && git commit -qm 'WIPE SAVEPOINT' && git reset HEAD~1 --hard
  r = rebase -i HEAD~15
	fc = "!f() { git log --pretty=format:'%C(yellow)%h  %Cblue%ad  %Creset%s%Cgreen  [%cn] %Cred%d' --decorate --date=short -S$1; }; f"
	fm = "!f() { git log --pretty=format:'%C(yellow)%h  %Cblue%ad  %Creset%s%Cgreen  [%cn] %Cred%d' --decorate --date=short --grep=$1; }; f"
	contributors = shortlog --summary --numbered

Global Ignore

Create the file ~/.gitignore as shown below to remove the files that are almost always ignored in all git repositories. more global git ignores can found on Github Gitignores.

# Folder view configuration files

# Thumbnail cache files

# Files that might appear on external disks

# VIM.

Export all configurations

  • open Emacs
  • type Alt-X and select org-babel-tangle
  • all set!
Chen Hsin-Yi
The Pointfree Combinator