# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi

alias vi=vim


# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions
# If adding new functions to this file, note that you can add help text to the function
# by defining a variable with name _<function>_help containing the help text


# Honcho has issues outputing UTF-8 in Vagrant SSH
# https://github.com/nickstenning/honcho/issues/51
export PYTHONIOENCODING=utf-8

export HUBS_CONFIG={{ hubs_conf_dir }}/hubs.py
export FLASK_APP={{ hubs_code_dir }}/hubs/app.py


workon() {
    [ "$1" == "hubs" ] || ( echo "No such virtualenv."; exit 1 )
    cd {{ hubs_code_dir }}
}

alias hup="pushd ~ ; honcho start ; popd"

hreset() {
    {% if hubs_db_type == "postgresql" %}
    sudo -u postgres dropdb hubs
    sudo -u postgres createdb -O hubs hubs
    {% else %}
    rm {{ hubs_var_dir }}/hubs.db
    {% endif %}
    rm {{ hubs_var_dir }}/cache.db
    pushd {{ hubs_code_dir }}
    python3 populate.py
    popd
}

# Enable autocomplete for the fedora-hubs command
eval "$(_FEDORA_HUBS_COMPLETE=source fedora-hubs)"
