aboutsummaryrefslogtreecommitdiffstats
path: root/nvchecker/nvtake.bash_completion
blob: 23776c2079c792bbf6d35989313efdc76a4d2eea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# MIT licensed
# Copyright (c) 2020 Felix Yan <felixonmars@archlinux.org>, et al.

_nvtake() {
    local cur _nvchecker_conf_mtime
    _init_completion || return

    _nvchecker_conf_mtime="$(stat -c %Y $HOME/.config/nvchecker/*)"
    if [ -z "$_nvtake_completion_cache" -o "$_nvchecker_conf_mtime" != "$_nvchecker_conf_mtime_cached" ]; then
        _nvtake_completion_cache="$(nvcmp -q)"
        _nvchecker_conf_mtime_cached="$_nvchecker_conf_mtime"
    fi

    COMPREPLY=( $(compgen -W "$_nvtake_completion_cache" -- "$cur") )
} &&
    complete -F _nvtake nvtake