diff --git a/autocompletion/README.md b/autocompletion/README.md deleted file mode 100644 index bf8ed086c3..0000000000 --- a/autocompletion/README.md +++ /dev/null @@ -1,56 +0,0 @@ -# Zowe Autocompletion for bash - -Autocompletion simplifies composing Zowe CLI commands. - -```sh -zowe -``` -displays available options, commands or command groups -```sh ---available-commands --response-format-json plugins provisioning zos-files zos-tso zosmf ---help --version config profiles zos-console zos-jobs zos-workflows -vlcvi01@VLCVI01W10:~/workspaces/zowe-cli/autocompletion$ zowe -``` - -At first glance it may look that autocompletion does not work because of very slow response time. This is caused by zowe cli performance. Autocompletion script runs `zowe ... --help` in background to extract suggestions. - -Live demonstration -[![asciicast](https://asciinema.org/a/243646.svg)](https://asciinema.org/a/243646) - -## Installation - -### Linux (Ubuntu) -1) copy `zowe.bash` file to `/etc/bash_completion.d/zowe.bash` - ``` - sudo cp zowe.bash /etc/bash_completion.d/zowe.bash - ``` -2) start a new `bash` terminal - -**NOTE**: files in `/etc/bash_completion.d` do not have to have execute privilege. - -If you don't have an access to `/etc/bash_completion.d/`, copy `zowe.bash` file to `~/zowe_autocompletion/zowe.bash` add -```sh -. ~/zowe_autocompletion/zowe.bash -``` -at the end of your `.bashrc` file. - -### Mac -1) enable bash completion on mac because it is not activated by default see instructions: -https://www.simplified.guide/macos/bash-completion - -2) copy `zowe.bash` file to `/usr/local/etc/bash_completion.d/zowe.bash` -3) start a new `bash` terminal - -> [!NOTE] -> Files in `/usr/local/etc/bash_completion.d/zowe.bash` do not have to have execute privilege. - -### Windows - * Windows CMD is not supported. - * WLS is supported (see Linux) - * bash via MINGW should work but you need: grep, awk - -## Troubleshooting -To enable debug messages of the autocompletion script uncomment `#logfile="log"`. `log` file is created in current directory. - -## Limitations -Listing of datasets is using the default zosmf profile. diff --git a/autocompletion/zowe.bash b/autocompletion/zowe.bash deleted file mode 100644 index b8bdf9575a..0000000000 --- a/autocompletion/zowe.bash +++ /dev/null @@ -1,66 +0,0 @@ -_ZOWE_COMPLETION() -{ - local cur prev opts zowe zoweout rc debug logfile usage - #logfile="log" - - if [ ! -z "$logfile" ]; then - rm -f $logfile ; touch $logfile - fi - - #skip - zowe="${COMP_WORDS[0]}" - #zowe="/home/vlcvi01/node_modules/.bin/zowe" - COMPREPLY=() - cur="${COMP_WORDS[COMP_CWORD]}" - prev="${COMP_WORDS[COMP_CWORD-1]}" - zowe="$zowe ${COMP_WORDS[@]:1:${COMP_CWORD}-1} --help" - zoweout=$(sh -c "${zowe} 2> /dev/null") - rc=$? - if [ $rc -ne 0 ] ; then - zowe="$zowe ${COMP_WORDS[@]:1:${COMP_CWORD}-2} --help" - zoweout=$(sh -c "${zowe} 2> /dev/null") - rc="${rc}/$?" - fi - - #opts="$(sh -c "$zowe ${COMP_WORDS[@]:1:${#COMP_WORDS[@]}-1} --help" | awk '/GROUPS/,/OPTIONS/' | grep '^ ' | awk '{print $1}') $(sh -c "$zowe ${COMP_WORDS[@]:1:${#COMP_WORDS[@]}-1} --help" | grep '^ --' | awk '{print $1}')" - opts="$( echo "$zoweout" | awk '/(COMMANDS|GROUPS)/,/OPTIONS/' | grep '^ ' | awk '{print $1}' ; echo "" ; echo "$zoweout" | grep '^ --' | awk '{print $1}' )" - - #check if USAGE part contains keyword in <> - # if generate list of local files - usage="$(echo "$zoweout" | grep -A 4 '^ USAGE' | grep -oP "${prev}\s+\K[^ ]*" )" - if [ ! -z "$usage" ] ; then - #zowe zos-jobs submit local-file [options] - if [ "$usage" = "" ]; then - COMPREPLY=( $(compgen -f ${cur}) ) - return 0 - fi - #zowe zos-files upload dir-to-pds [options] - if [ "$usage" = "" ]; then - COMPREPLY=( $(compgen -f ${cur}) ) - return 0 - fi - #zowe profiles update zosmf-profile [options] - - #zowe zos-files download data-set [options] - if [ "$usage" = "" ]; then - COMPREPLY=( $(compgen -W "$(zowe zos-files list data-set $(whoami) 2> /dev/null )" -- ${cur} ) ) - return 0 - fi - opts="$opts $usage" - fi - - if [ ! -z "$logfile" ]; then - echo "!${zoweout}!" >>$logfile - echo "usage:~$usage~" >> $logfile - echo "cli:~${zowe}~" >>$logfile - echo "rc:~${rc}~" >>$logfile - echo "opts:~${opts}~" >>$logfile - echo "cur:~${cur}~last:${prev}~" >>$logfile - echo "COMP_WORDS:${COMP_WORDS[@]}~${COMP_CWORD}~" >>$logfile - echo "~~~~~~~~~~~~~~~~~~~~" >>$logfile - fi - - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) -} - -complete -F _ZOWE_COMPLETION zowe \ No newline at end of file