aboutsummaryrefslogtreecommitdiffstats
path: root/ariketa.sh
blob: 658588fea5f59730f6b10f603ea94103a3985a8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash

_ariketa.dir () {
    local _ariketa_filename _ariketa_dir
    _ariketa_filename="${BASH_SOURCE[$(( ${#BASH_SOURCE[@]} - 1 ))]}"
    [[ "$_ariketa_filename" == */* ]] && _ariketa_dir="${_ariketa_filename%/*}"

    # get an absolute path to ariketa in case we need it
    _ariketa_dir=$(cd "${_ariketa_dir:-$PWD}" && printf "%s" "$PWD")
    printf "%s" "$_ariketa_dir"
}


_ariketa.help () {
    >&2 printf "%s\n" "$(<USAGE)"
    return 1
}

_sourced? () {
    [[ ${FUNCNAME[$(( ${#FUNCNAME[@]} - 1 ))]} == "source" ]]
}

_sourced? || {
    _ariketa.help
    exit $?
}

ARIKETA_DIR=$(_ariketa.dir)

# preserve multiline commands as such in history
shopt -s lithist

# load presentation prompt
source "${ARIKETA_DIR:?}/lib/prompt.sh"

# load misc functions
source "${ARIKETA_DIR:?}/lib/functions.sh"

# set up bash macros to page through examples
source "${ARIKETA_DIR:?}/lib/bindings.sh"

# load examples array
source "${ARIKETA_DIR:?}/config/examples.sh"

# unset example index/directionality markers
unset _I _D