xaizek / dit (License: GPLv3) (since 2018-12-07)
Command-line task keeper that remembers all old values and is meant to combine several orthogonal features to be rather flexible in managing items.
<root> / scripts / bash-completion (1f8606f71527a80b9c1e99b1f77fe64887ceb52f) (1,834B) (mode 100755) [raw]
#!/bin/bash

complete -F _dit dit

# arguments completion function
function _dit()
{
    local args=( ${COMP_LINE:0:$COMP_POINT}::cursor:: )
    unset args[0]
    local cur="${args[-1]}"
    cur="${cur:0:-10}"

    # do not innsert trailing space
    compopt -o nospace

    if [ "${COMP_LINE:$(( $COMP_POINT - 1 ))}" = '=' ]; then
        # try to fix issues related to use of = as a word separator (this is
        # a readline setting, which we can't control per command completion)
        cur=
    fi

    # obtain completion from the application
    local compl="$(dit complete ${args[@]})"
    local OLDIFS="$IFS"
    IFS=$'\n'
    COMPREPLY=( $( compgen -W "$compl" -- "$cur" ) )
    IFS="$OLDIFS"

    # try to properly escape completion results
    # based on snipped from: http://stackoverflow.com/a/1146716/1535516
    local escaped_single_qoute="'\''"
    local i=0
    for entry in "${COMPREPLY[@]}"; do
        if [[ "${cur:0:1}" == "'" ]]; then
            # started with single quote, escaping only other single quotes
            # [']bla'bla"bla\bla bla --> [']bla'\''bla"bla\bla bla
            COMPREPLY[$i]="${entry//\'/${escaped_single_qoute}}"
        elif [[ "${cur:0:1}" == '"' ]]; then
            # started with double quote, escaping all double quotes and all
            # backslashes
            # ["]bla'bla"bla\bla bla --> ["]bla'bla\"bla\\bla bla
            entry="${entry//\\/\\\\}"
            COMPREPLY[$i]="${entry//\"/\\\"}"
        else
            # no quotes in front, escaping _everything_
            # [ ]bla'bla"bla\bla bla --> [ ]bla\'bla\"bla\\bla\ bla
            entry="${entry//\\/\\\\}"
            entry="${entry//\'/\'}"
            entry="${entry//\"/\\\"}"
            entry="${entry//|/\\|}"
            COMPREPLY[$i]="${entry// /\\ }"
        fi
        (( i++ ))
    done
}
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/dit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/dit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master