Skip to content

Instantly share code, notes, and snippets.

@uyriq
Created February 22, 2024 11:38
Show Gist options
  • Save uyriq/e715172601df79b0726409748549485b to your computer and use it in GitHub Desktop.
Save uyriq/e715172601df79b0726409748549485b to your computer and use it in GitHub Desktop.
part of ,bashrc for tea command tunning. How to add --repo "reponame" automaticaly postfix based on current repo
# work but badly way
gitea() {
reponame="basename -s .git $(git config --get remote.origin.url)"
giteaargs="$@"
tea $giteaargs --repo $reponame
}
PROG2=gitea
_cli_bash_autocomplete() {
if [[ "${COMP_WORDS[0]}" != "source" ]]; then
local cur opts base
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
if [[ "$cur" == "-"* ]]; then
opts=$(${COMP_WORDS[@]:0:$COMP_CWORD} ${cur} --generate-bash-completion)
else
opts=$(${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion)
fi
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
fi
}
complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete $PROG2
unset PROG2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment