Anders's dotfiles

These are my dotfiles, which may or may not be helpful to you.


There are a number of tools I always seem to end up using. Some of these change over time. Some seem to more or less stay the same. For a while, I preferred MacPorts. These days I prefer Homebrew. Mostly, things stay more or less the same.

You probably want to install these manually before proceeding:

There are a number of other apps which I tend to install. You can have a look at the list and maybe feel inspired.


To set up your local computer just the way I like it, run:
bash <(curl -s

On to the dotfiles

The easiest way to use any one of these is with curl:

cd;curl -O{.whatever}



There are several things going on here:


# Load bash completions
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion

# TextMate is still my favorite general purpose editor
export EDITOR="mate -w"

# Activate a named docker machine
docker-machine-set-active() {
  eval $(docker-machine env $1)

# Create digital ocean droplet
docker-create-droplet() {
  if [[ "$1" == "" || "$2" == "" || "$3" == "" ]] ; then
    echo "USAGE: docker-create-droplet TOKEN REGION NAME"
    echo "  TOKEN   the Digital Ocean access token"
    echo "  REGION  the region in which the droplet should be created"
    echo "  NAME    the name of the droplet"
  docker-machine create --driver digitalocean --digitalocean-image ubuntu-16-04-x64 --digitalocean-access-token $1 --digitalocean-region $2 $3

docker-restart-droplet() {
  if [[ "$1" == "" || "$2" == "" ]] ; then
    echo "USAGE: docker-restart-droplet NAME ENVIRONMENT"
    echo "  NAME         the name of the service"
    echo "  ENVIRONMENT  the environment the service will run in"
  echo -n "Stopping $1..."
  docker stop $1 >/dev/null 2>&1
  echo -e "   \033[32mdone\033[39m"
  echo -n "Cleaning $1..."
  docker rm $1 >/dev/null 2>&1
  echo -e "   \033[32mdone\033[39m"
  echo -n "Starting $1..."
  result=`docker run --name $1 -d --restart always $1:$2`
  if [[ "$?" == "0" ]] ; then
    echo -e "   \033[32mdone\033[39m"
    echo -e "   \033[31m$result\033[39m"

# Open specified xcode project or workspace, or open a workspace or project in specified directory
xcode() {
  if [[ "$1" != "" ]] ; then
    if [ ! -d $1 ] ; then
      open -a Xcode $1

  workspaces=( $(ls -d $dir/*.xcworkspace 2>/dev/null) )
  projects=( $(ls -d $dir/*.xcodeproj 2>/dev/null) )

  case ${#workspaces[@]} in
    case ${#projects[@]} in
      echo -e "\033[31mNo Xcode projects found in `dirname $dir`\033[39m"
      sleep 100
      open -a Xcode ${projects[0]}
    open -a Xcode ${workspaces[0]}

  echo -e "\033[31mMore than one project or workspace found:\033[39m"
  echo ""
  ls -d *.xcworkspace *.xcodeproj
  echo ""
  echo -e "\033[32mPlease specify one.\033[39m"

Raw .bash_profile



There are a lot of things git can do from the command line which to a large degree render UI tools irellevant. Formatting log output to add color and tree view goes a long way towards that. Also included in this is a set of shortcuts that I have committed to muscle memory since the days when I was using SVN. Added them as aliases in git just made sense.

  name = YOUR_NAME
  excludesfile = ABSOLUTE_PATH_TO_HOME/.gitignore_global
  # Make rebase safe on osx
  rebase = -c core.trustctime=false rebase

  # A couple of shortcuts because I used to use svn
  ci = commit
  co = checkout
  st = status

  # Log, but with tree, colors, and changed files list
  lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --name-status

  # Log, just with tree
  tree = log --graph --oneline --all --color --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit

  # Pull HEAD of master in all submodules
  sp = submodule foreach --recursive git fetch origin --tags && git checkout master && git pull
  # Initialize all submodules
  su = submodule update --init --recursive

  # Clone submodules when cloning a repository
  clone = clone --recurse

  # Words that are too long for me to bother with them
  br = branch
  ch = cherry-pick

  # Rebase local changes on top of anything you pull without nagging about local uncommitted changes
  pr = !git stash && git pull --rebase && git stash pop

  # Fast forward pull - should be the default imho
  pf = pull --ff-only

  # Set upstream when pushing - should be default imho
  pu = push -u

  # Merge without implicitly creating merge commits
  mf = merge --ff-only
  # Delete a remote branch
  bd = push origin --delete

  # Use OSX keychain to remember passwords
  helper = osxkeychain

  # Assume that local branch name matches remote branch name
  default = current

  # Use https for github (obviously)
  protocol = https

Raw .gitconfig



Because we specified it in .gitconfig and because everyone on OSX should ignore .DS_Store files.

# emacs backup file should always be ignored

# OSX folder metadata is everywhere and should always be ignored

# Xcode stores its state in this subfolder, and too many people forget to ignore it

Raw .gitignore_global



Because telnet to a serial device by default doesn't provice the capabilities we are used to in a terminal. This allows us to scroll normally.

termcapinfo xterm* ti@:te@

Raw .screenrc



# Keep connections alive by sending a null packet every 30 seconds
ServerAliveInterval 30
Host wedding
  User wedding
  # Allow editing remote files with rmate
  RemoteForward 52698 localhost:52698
Host magellanic
  User cyborch
  # Allow editing remote files with rmate
  RemoteForward 52698 localhost:52698

Raw .ssh/config