# -*- mode: sh -*-
# shellcheck shell=bash

function mb-powerline-go-prompt {
    PS1="$(powerline-go                                                        \
          -error $?                                                            \
          -jobs "$(jobs -p | wc -l)"                                           \
          -cwd-max-depth 4                                                     \
          -hostname-only-if-ssh                                                \
          -newline                                                             \
          -numeric-exit-codes                                                  \
          -venv-name-size-limit 1                                              \
          -git-disable-stats "ahead,behind,staged,notStaged,untracked,stashed" \
          -modules "user,host,ssh,kube,dotenv,venv,git,cwd,perms,jobs,exit"    \
          )"
}

################################################################################

function mb-fancy-prompt {
    PROMPT_COMMAND="mb-powerline-go-prompt; ${PROMPT_COMMAND}"
}

function mb-lofi-prompt {
    local git_ps workdir

    # Git prompt
    if [ -f /usr/share/git-core/contrib/completion/git-prompt.sh ]; then
        source /usr/share/git-core/contrib/completion/git-prompt.sh
    fi

    # Tmux
    if [[ -n "${TMUX}" ]]; then
        PSE="[\[\e[0;31m\]TMUX\[\e[00m\]]"
    fi

    git_ps="\$(type __git_ps1 1>/dev/null 2>/dev/null && __git_ps1)"
    workdir="\[\e[0;33m\]\w\[\e[00m\]"

    export PROMPT_DIRTRIM=3
    export PS1="\[\e[0;32m\]\u\[\e[00m\]${PSE} ${workdir}${git_ps} \$ "
}
