From 874429fe10bdbf3c6f658d28e718d13ae916fc7a Mon Sep 17 00:00:00 2001 From: gursheyss Date: Sat, 17 Feb 2024 13:10:12 -0800 Subject: [PATCH 1/4] add bash completions --- .gitignore | 1 + sce.sh | 1 + sce_completion.sh | 15 +++++++++++++++ 3 files changed, 17 insertions(+) create mode 100644 sce_completion.sh diff --git a/.gitignore b/.gitignore index d1c9076..5c9b4fa 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ !README.md !sce.bat !sce.sh +!sce_completion.sh \ No newline at end of file diff --git a/sce.sh b/sce.sh index 0a79c58..44586ec 100755 --- a/sce.sh +++ b/sce.sh @@ -110,6 +110,7 @@ then # For other shells (Bash, Zsh, etc.) echo "# for the sce dev tool" echo "alias sce=\"$(pwd)/sce.sh\"" + echo "source \"$(pwd)/sce_completion.sh\"" echo "" exit 0 fi diff --git a/sce_completion.sh b/sce_completion.sh new file mode 100644 index 0000000..4364bd1 --- /dev/null +++ b/sce_completion.sh @@ -0,0 +1,15 @@ +# !/bin/bash + +_sce_completion() { + local cur prev opts + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + opts="clone run link setup completion" + + if [[ ${cur} == * ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 + fi +} +complete -F _sce_completion sce \ No newline at end of file From d83b12afa62bfc7017f59e4fcbac002de322403a Mon Sep 17 00:00:00 2001 From: gursheyss Date: Mon, 19 Feb 2024 09:52:48 -0800 Subject: [PATCH 2/4] add repo completion --- sce_completion.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sce_completion.sh b/sce_completion.sh index 4364bd1..d745dd1 100644 --- a/sce_completion.sh +++ b/sce_completion.sh @@ -1,4 +1,4 @@ -# !/bin/bash +#!/bin/bash _sce_completion() { local cur prev opts @@ -6,6 +6,12 @@ _sce_completion() { cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" opts="clone run link setup completion" + repos="Clark cleezy Quasar SCE-discord-bot SCEta" + + if [[ ${prev} == "clone" || ${prev} == "run" || ${prev} == "link" ]] ; then + COMPREPLY=( $(compgen -W "${repos}" -- ${cur}) ) + return 0 + fi if [[ ${cur} == * ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) From 98e4be7a099922280f23deec7a89cd50a1e52419 Mon Sep 17 00:00:00 2001 From: gursheyss Date: Sun, 25 Feb 2024 16:15:32 -0800 Subject: [PATCH 3/4] Add fallback completion options if no matches found --- sce_completion.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sce_completion.sh b/sce_completion.sh index d745dd1..656b129 100644 --- a/sce_completion.sh +++ b/sce_completion.sh @@ -10,11 +10,17 @@ _sce_completion() { if [[ ${prev} == "clone" || ${prev} == "run" || ${prev} == "link" ]] ; then COMPREPLY=( $(compgen -W "${repos}" -- ${cur}) ) + if [[ ${#COMPREPLY[@]} -eq 0 ]]; then + COMPREPLY=( $(ls) ) + fi return 0 fi if [[ ${cur} == * ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + if [[ ${#COMPREPLY[@]} -eq 0 ]]; then + COMPREPLY=( $(ls) ) + fi return 0 fi } From e308a92a722f9c640aa1469f7c81b6d99a956b58 Mon Sep 17 00:00:00 2001 From: gursheyss Date: Tue, 5 Mar 2024 02:39:19 -0800 Subject: [PATCH 4/4] kinda fix ls --- sce_completion.sh | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/sce_completion.sh b/sce_completion.sh index 656b129..d934432 100644 --- a/sce_completion.sh +++ b/sce_completion.sh @@ -1,27 +1,23 @@ #!/bin/bash _sce_completion() { - local cur prev opts + local cur prev opts repos COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" opts="clone run link setup completion" repos="Clark cleezy Quasar SCE-discord-bot SCEta" - if [[ ${prev} == "clone" || ${prev} == "run" || ${prev} == "link" ]] ; then + if [[ ${prev} == "clone" || ${prev} == "run" || ${prev} == "link" ]]; then COMPREPLY=( $(compgen -W "${repos}" -- ${cur}) ) - if [[ ${#COMPREPLY[@]} -eq 0 ]]; then - COMPREPLY=( $(ls) ) - fi - return 0 + else + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) fi - if [[ ${cur} == * ]] ; then - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) - if [[ ${#COMPREPLY[@]} -eq 0 ]]; then - COMPREPLY=( $(ls) ) - fi - return 0 + if [[ ${#COMPREPLY[@]} -eq 0 ]]; then + COMPREPLY=( $(compgen -o default -- ${cur}) ) fi + + return 0 } -complete -F _sce_completion sce \ No newline at end of file +complete -F _sce_completion sce