Skip to content

Commit

Permalink
add install-ccache completion
Browse files Browse the repository at this point in the history
  • Loading branch information
JensDll committed Jul 30, 2023
1 parent d1382b9 commit 3657454
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion scripts/shellcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ root="$(
declare -r root
declare -r unix="$root/unix"

shellcheck --external-sources "$root"/**/*.sh "$unix"/.local/**/*.sh \
shellcheck --external-sources "$root"/**/*.sh "$unix"/.local/bin/* "$unix"/.local/share/bash-completion/completions/* \
"$unix/.bash_aliases" "$unix/.bash_logout" "$unix/.bashrc" "$unix/.profile"
6 changes: 6 additions & 0 deletions unix/.inputrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#index-show_002dall_002dif_002dambiguous
set show-all-if-ambiguous on
# https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#index-visible_002dstats
set visible-stats on
# https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#index-page_002dcompletions
set page-completions off
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

# bash -s <version> < <(curl --location --fail --silent --show-error https://raw.githubusercontent.com/JensDll/dotfiles/main/unix/.local/bin/install-ccache.sh)
# bash -s <version> < <(curl --location --fail --silent --show-error https://raw.githubusercontent.com/JensDll/dotfiles/main/unix/.local/bin/install-ccache)

# https://ccache.dev

Expand All @@ -10,7 +10,7 @@ declare -r green="\033[0;32m"

__usage() {
# https://manpages.debian.org/coreutils/cat
cat << EOF
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") <version> [options]
Options: [defaults in brackets after descriptions]
--help | -h | -? print this message
Expand Down Expand Up @@ -99,7 +99,7 @@ declare -r temp_dir
trap '__cleanup $temp_dir' EXIT

# https://manpages.debian.org/gpg/gpg
if ! gpg --list-public-keys '5A939A71A46792CF57866A51996DDA075594ADB8' > /dev/null 2>&1; then
if ! gpg --list-public-keys '5A939A71A46792CF57866A51996DDA075594ADB8' >/dev/null 2>&1; then
gpg --keyserver hkps://keyserver.ubuntu.com --receive-keys '5A939A71A46792CF57866A51996DDA075594ADB8'
fi

Expand Down
22 changes: 22 additions & 0 deletions unix/.local/share/bash-completion/completions/install-ccache.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
__install_ccache_debug() {
if [[ -n ${BASH_COMP_DEBUG_FILE:-} ]]; then
echo "$*" >>"$BASH_COMP_DEBUG_FILE"
fi
}

__start_install_ccache() {
local cur prev words cword

_init_completion || return

__install_ccache_debug
__install_ccache_debug '========= starting install-ccache completion logic =========='
__install_ccache_debug "cur = $cur, prev = $prev, words[*] = ${words[*]}, #words[@] = ${#words[@]}, cword is $cword"

if [[ $cur = -* ]]; then
# shellcheck disable=SC2016
mapfile -t COMPREPLY < <(compgen -W '$(_parse_help "$1")' -- "$cur")
fi
}

complete -o default -F __start_install_ccache install-ccache

0 comments on commit 3657454

Please sign in to comment.