# Create a new directory and enter it.
mkcd() {
  mkdir -p "./$1" && cd "./$1"
}

# Fuzzy cd into selected directory.
fd() {
  local dir
  dir=$(find ${1:-.} -path '*/\.*' -prune \
                  -o -type d -print 2> /dev/null | fzf --height=50% --border) &&
  cd "$dir"
}

docker_clean() {
  docker rm -vf $(docker ps -a -q)
  docker rmi -f $(docker images -a -q)
}

# Create a new directory and enter it.
mkcd() {
  mkdir -p "./$1" && cd "./$1"
}

# Fuzzy cd into selected directory.
fd() {
  local dir
  dir=$(find ${1:-.} -path '*/\.*' -prune \
                  -o -type d -print 2> /dev/null | fzf --height=50% --border) &&
  cd "$dir"
}

docker_clean() {
  docker rm -vf $(docker ps -a -q)
  docker rmi -f $(docker images -a -q)
}

# Browse Google Chrome history and open selected link in default browser.
c() {
  local cols sep
  export cols=$(( COLUMNS / 3 ))
  export sep='{::}'

  cp -f ~/Library/Application\ Support/Google/Chrome/Default/History /tmp/h
  sqlite3 -separator $sep /tmp/h \
    "select title, url from urls order by last_visit_time desc" |
  ruby -ne '
    cols = ENV["cols"].to_i
    title, url = $_.split(ENV["sep"])
    len = 0
    puts "\x1b[36m" + title.each_char.take_while { |e|
      if len < cols
        len += e =~ /\p{Han}|\p{Katakana}|\p{Hiragana}|\p{Hangul}/ ? 2 : 1
      end
    }.join + " " * (2 + cols - len) + "\x1b[m" + url' |
  fzf --ansi --multi --no-hscroll --tiebreak=index |
  sed 's#.*\(https*://\)#\1#' | xargs open
}

Add command to browse Google Chrome history from terminal
Add command to browse Google Chrome history from terminal
