if test -e "${HOME}/.config/liquidprompt"; then
	source "${HOME}/.config/liquidprompt"

_lp_nat_theme_activate() {
    _lp_default_theme_activate

    local lp_terminal_format
    lp_terminal_format 6 -1
    _LP_NAT_STRUCT_COLOR="${lp_terminal_format}"
    _LP_NAT_FIELD_COLOR="${NO_COL}"
}

_lp_nat_theme_directory() {
    _lp_default_theme_directory
}

_lp_nat_theme_prompt() {
  local topleft="${_LP_NAT_STRUCT_COLOR}┌"
  local middleleft="${_LP_NAT_STRUCT_COLOR}├"
# local bottomleft="${_LP_NAT_STRUCT_COLOR}└"
  local middlevert="${_LP_NAT_STRUCT_COLOR}│"
  local topright="${_LP_NAT_STRUCT_COLOR}┐"
  local bottomright="${_LP_NAT_STRUCT_COLOR}┘"
# local left="${topleft}${_LP_NAT_FIELD_COLOR}─${LP_BRACKET_OPEN}${LP_USER}${LP_HOST}${LP_BRACKET_CLOSE}─${_LP_NAT_STRUCT_COLOR}"
  local left="${topleft}${_LP_NAT_FIELD_COLOR}─${LP_BRACKET_OPEN}${LP_USER}${LP_HOST}"
  local right="${LP_PWD}${LP_MARK_BRACKET_CLOSE}─${NO_COL}"
# local main="${NO_COL}${LP_RUNTIME}${LP_ERR}${LP_MARK_PREFIX}${LP_COLOR_MARK}${LP_MARK_DEFAULT}${LP_PS1_POSTFIX}${NO_COL}"
  local vcs=""
  local main=""
  local mark="${LP_COLOR_MARK}${LP_MARK_DEFAULT}${NO_COL} "
  local n=$'\n'

  if _lp_shell_level_color; then
    left+="${_LP_NAT_FIELD_COLOR}:${lp_shell_level_color}"
  fi
  if _lp_jobcount_color; then
    left+="${_LP_NAT_FIELD_COLOR}:${lp_jobcount_color}"
  fi
  left+="${LP_BRACKET_CLOSE}─${_LP_NAT_STRUCT_COLOR}"

  if _lp_dirstack; then
    if (( lp_dirstack >= ${LP_NAT_DIRSTACK_MIN_NUM:-5} )); then
      right="${LP_MARK_BRACKET_OPEN}${LP_COLOR_DIRSTACK}${lp_dirstack}${LP_MARK_DIRSTACK}${_LP_NAT_FIELD_COLOR}${right}"
    else
      local i
      for (( i=0; i < lp_dirstack; i++ )) ; do
        right="${LP_MARK_BRACKET_OPEN}${right}"
      done
    fi
  else
    right="${LP_MARK_BRACKET_OPEN}${right}"
  fi

  if _lp_fill "${left}" "${_LP_NAT_FIELD_COLOR}─${right}" "─"; then
    PS1="${lp_fill}${n}"
  else
    _lp_fill "${left}" "${topright}" "─"
    PS1="${lp_fill}${n}"
    _lp_fill "${middlevert}" "${_LP_NAT_FIELD_COLOR}${right}${bottomright}"
    PS1+="${lp_fill}${NO_COL}${n}"
  fi

  if _lp_find_vcs && _lp_vcs_details_color; then
    # lp_vcs_details_color:
    #   branch/bookmark/tag/commit-id
    #     red when uncommitted/unstaged changes ($LP_COLOR_CHANGES)
    #     bold red when behind remote ($LP_COLOR_COMMITS_BEHIND)
    #     yellow when ahead remote ($LP_COLOR_COMMITS)
    #     green otherwise ($LP_COLOR_UP)
    #   (
    #   +$lp_vcs_uncommited_i_lines/$lp_vcs_uncommited_d_lines
    #     purple ($LP_COLOR_DIFF)
    #   ,
    #   +$lp_vcs_commit_ahead/-$lp_vcs_commit_behind
    #     yellow ($LP_COLOR_COMMITS)
    #   )
    #   + when stash is not empty (red)
    #   * when untracked files (yellow)
    #   head status (merging, rebasing, etc)
    #   remote status after ${LP_MARK_VCS_REMOTE:-\u2B5A}
    vcs+="${NO_COL} ${lp_vcs_type} ${lp_vcs_details_color}"
  fi

  if _lp_error_color; then
    main+=" $lp_error_color"
    if _lp_error_meaning_color; then
      main+="$lp_error_meaning_color"
    fi
  fi
  if _lp_runtime_color; then
    main+=" $lp_runtime_color"
    if _lp_time_color; then
      main+=" $lp_time_color"
    fi
  fi

  if test -n "$vcs" && test -n "$main" && _lp_fill "${middleleft}─$main" "$vcs"; then
    PS1+="${lp_fill}${n}"
  else
    if test -n "$vcs"; then
      PS1+="${middleleft}─${vcs}${n}"
    fi
    if test -n "$main"; then
      PS1+="${middleleft}─${main}${n}"
    fi
  fi

  PS1+="${mark}"
  PS2="${_LP_NAT_FIELD_COLOR}(${_LP_NAT_STRUCT_COLOR}%_${_LP_NAT_FIELD_COLOR})${NO_COL} "
}

	lp_theme nat

	return
fi

# Fallback Prompt
function precmd {
    PR_STATUS=$?

    local TERMWIDTH
    (( TERMWIDTH = ${COLUMNS} - 1 ))


    ###
    # Truncate the path if it's too long.
    
    PR_FILLBAR=""
    PR_PWDLEN=""
    
    local promptsize=${#${(%):---(%n@%m:%l)---()-}}
    local pwdsize=${#${(%):-%~}}
    
    if [[ "$promptsize + $pwdsize" -gt $TERMWIDTH ]]; then
	    ((PR_PWDLEN=$TERMWIDTH - $promptsize))
    else
	PR_FILLBAR="\${(l.(($TERMWIDTH - ($promptsize + $pwdsize)))..${PR_HBAR}.)}"
    fi


}


setopt extended_glob
preexec () {
    if [[ "$TERM" == "screen" ]]; then
	local CMD=${1[(wr)^(*=*|sudo|-*)]}
	echo -n "\ek$CMD\e\\"
    fi
}


setprompt () {
    ###
    # Need this so the prompt will work.

    setopt prompt_subst


    ###
    # See if we can use colors.

    autoload colors zsh/terminfo
    if [[ "$terminfo[colors]" -ge 8 ]]; then
	colors
    fi
    for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
	eval PR_BOLD_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
	eval PR_$color='%{$fg[${(L)color}]%}'
	(( count = $count + 1 ))
    done
    PR_NO_COLOUR="%{$terminfo[sgr0]%}"


    ###
    # See if we can use extended characters to look nicer.
    
    PR_HBAR="─"
    PR_ULCORNER="┌"
    PR_LLCORNER="└"
    PR_LRCORNER="┘"
    PR_URCORNER="┐"

    
    ###
    # Decide whether to set a screen title
    if [[ "$TERM" == "screen" ]]; then
	PR_STITLE=$'%{\ekzsh\e\\%}'
    else
	PR_STITLE=''
    fi
    

    ###
    # Finally, the prompt.

    PROMPT='$PR_STITLE\
$PR_CYAN$PR_ULCORNER$PR_BLUE$PR_HBAR(\
$PR_GREEN%(!.%SROOT%s.%n)$PR_GREEN@%m:%l\
$PR_BLUE)$PR_HBAR$PR_CYAN$PR_HBAR${(e)PR_FILLBAR}$PR_BLUE$PR_HBAR(\
$PR_MAGENTA%$PR_PWDLEN<...<%~%<<\
$PR_BLUE)$PR_HBAR\

$PR_CYAN$PR_LLCORNER \
${${PR_STATUS:#0}:+$PR_RED$PR_STATUS$PR_BLUE:\
$PR_RED${signals[$PR_STATUS-127]}${signals[$PR_STATUS-127]:+$PR_BLUE:}}\
%(!.$PR_RED.$PR_WHITE)%#\
$PR_NO_COLOUR '

    RPROMPT=''

    PS2='$PR_CYAN$PR_HBAR\
$PR_BLUE$PR_HBAR(\
$PR_GREEN%_$PR_BLUE)$PR_HBAR\
$PR_CYAN$PR_HBAR$PR_NO_COLOUR '
}

setprompt
