function __quicknav_cd() {
  cd "$@"
}

function __quicknav_nav() {
  if [ "$#" -eq 0 ]; then
    quicknav --help
    return 0
  else
    local __quicknav_result
    __quicknav_result="$(quicknav get "$@")"

    if [ $? -eq 0 ]; then
      __quicknav_cd "$__quicknav_result"
      return 0
    else
      echo -e "\033[0;31m$__quicknav_result"
      return 1
    fi
  fi
}

function nav() {
  __quicknav_nav "$@"
}
