turbaszek commented on a change in pull request #9685:
URL: https://github.com/apache/airflow/pull/9685#discussion_r450091074



##########
File path: breeze
##########
@@ -228,62 +228,80 @@ function initialize_virtualenv() {
 # Sets up autocomplete for Breeze for both - bash and zsh
 function setup_autocomplete() {
     echo "Installing bash/zsh completion for local user"
-    echo "Note that completion for zsh is just limited to flags - without 
their values"
     echo
-    echo
-    set +e
-    grep ".bash_completion.d" "${HOME}/.bashrc" >/dev/null 2>&1
-    RES=$?
-    set -e
-    if [[ "${RES}" == "0" ]]; then
-        echo >&2
-        echo >&2 "ERROR:  Bash completion already setup before."
-        echo >&2
-        exit 1
-    fi
     "${AIRFLOW_SOURCES}/confirm" "This will create ~/.bash_completion.d/ 
directory and modify ~/.*rc files"
     echo
     echo
     mkdir -pv ~/.bash_completion.d
     ln -sf "${AIRFLOW_SOURCES}/breeze-complete" "${HOME}/.bash_completion.d/"
-    touch ~/.bashrc
-    cat >>~/.bashrc <<"EOF"
+    echo
+    echo "Breeze Bash completion is linked to: 
${AIRFLOW_SOURCES}/breeze-complete now."
+    echo
+    local BREEZE_COMMENT="Added by Airflow Breeze autocomplete setup"
+    if ! grep "${BREEZE_COMMENT}" "${HOME}/.bashrc" >/dev/null 2>&1; then
+        touch ~/.bashrc
+        # shellcheck disable=SC2129
+        echo "# START: ${BREEZE_COMMENT}" >>~/.bashrc
+        cat <<"EOF" >>~/.bashrc
 for BCFILE in ~/.bash_completion.d/* ; do
     . ${BCFILE}
 done
 EOF
-    cat >>~/.zshrc <<"EOF"
+        echo "# END: ${BREEZE_COMMENT}" >>~/.bashrc
+        echo
+        echo "The ${HOME}/.bashrc has been modified"
+        echo
+    else
+        echo
+        echo "The ${HOME}/.bashrc was already modified before. Not changing 
it."
+        echo
+    fi
+    if ! grep "${BREEZE_COMMENT}" "${HOME}/.zshrc" >/dev/null 2>&1; then
+        # shellcheck disable=SC2129
+        echo "# START: ${BREEZE_COMMENT}" >>~/.zshrc
+        cat <<"EOF" >>~/.zshrc
 autoload compinit && compinit
 autoload bashcompinit && bashcompinit
 source ~/.bash_completion.d/breeze-complete
 EOF
+        echo "# END: ${BREEZE_COMMENT}" >>~/.zshrc
+        echo
+        echo "The ${HOME}/.zshrc has been modified"
+        echo

Review comment:
       Not sure if it's a good practice to modify `.zshrc` file. Most 
autocompletes I met suggest user do
   ```
   echo "source <(xyz completion zsh)" >> ~/.zshrc
   ```
   In this way I'm fully aware of what's going on. Moreover, I personally keep 
my `.zshrc` in order so I would probably prefer to add this manually in 
"Autocompletes" section 😉 
   
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to