Repository: apache/airflow
Pull request: Breeze should load local tmux configuration in 'breeze start-airflow' 
closes #15416 

---
**Description**

Currently, when we run 

`
breeze start-airflow
`

**breeze** doesn't load local tmux configuration file **.tmux.conf** and we get default tmux configuration inside the containers.

**PR effect**
After this change developers will be able to put their **.tmux.conf** file as **/files/airflow-breeze-config/.tmux.conf**
and Breeze will load local **tmux configuration** in to the containers and developers should be able to use their local configurations.


Problem statement:
breeze should load local tmux configuration in 'breeze start-airflow'
**Description**

Currently, when we run 

`
breeze start-airflow
`

**breeze** doesn't load local tmux configuration file **.tmux.conf** and we get default tmux configuration inside the containers.

**Use case / motivation**

Breeze must load local **tmux configuration** in to the containers and developers should be able to use their local configurations.

**Are you willing to submit a PR?**
YES
<!--- We accept contributions! -->

**Related Issues**
None
<!-- Is there currently another issue associated with this? -->

Hints from issue discussion:
SGTM. Can you submit a PR?
I wondered about this a while ago (mostly because I don’t want to repeatedly `set mouse on`). The problem is any slightly sophisticated local tmux setup would contain a lot of dependencies and it’s not realistic to pull them all into the container. So maybe a better approach would be have a directory in the repository; if the user puts a (git-ignored) `.tmux.conf` file in it, the file is mounted to the container’s `~/.tmux.conf`.
> SGTM. Can you submit a PR?

Yes I will.
We already have similar mechanism for reading user-supplied env variables placed in `files/airflow-breeze-config` folder.
 https://github.com/apache/airflow/blob/130f9e32f49e10511863d05c03f3532269ae27db/scripts/in_container/configure_environment.sh#L36


It could be done in a very similar way .
> We already have similar mechanism for reading user-supplied env variables placed in `files/airflow-breeze-config` folder.
> https://github.com/apache/airflow/blob/130f9e32f49e10511863d05c03f3532269ae27db/scripts/in_container/configure_environment.sh#L36
> 
> It could be done in a very similar way .

thanks @potiuk, let me check.

Commit message: #15416 - Docs changed

Patch to review:
diff --git a/BREEZE.rst b/BREEZE.rst
index 4916b4ef63faf..7e626935d279c 100644
--- a/BREEZE.rst
+++ b/BREEZE.rst
@@ -258,11 +258,16 @@ You should set up the autocomplete option automatically by running:
 
 You get the auto-completion working when you re-enter the shell.
 
+Customize your environment
+--------------------------
 When you enter the Breeze environment, automatically an environment file is sourced from
 ``files/airflow-breeze-config/variables.env``. The ``files`` folder from your local sources is
 automatically mounted to the container under ``/files`` path and you can put there any files you want
 to make available for the Breeze container.
 
+You can also add your local tmux configuration in ``files/airflow-breeze-config/.tmux.conf`` and
+these configurations will be available for your tmux environment.
+
 .. raw:: html
 
     <div align="center">
diff --git a/scripts/in_container/configure_environment.sh b/scripts/in_container/configure_environment.sh
index 01c3487ef7cd4..8292f783fb1a6 100644
--- a/scripts/in_container/configure_environment.sh
+++ b/scripts/in_container/configure_environment.sh
@@ -19,6 +19,7 @@
 export FILES_DIR="/files"
 export AIRFLOW_BREEZE_CONFIG_DIR="${FILES_DIR}/airflow-breeze-config"
 VARIABLES_ENV_FILE="variables.env"
+TMUX_CONF_FILE=".tmux.conf"
 
 if [[ -d "${FILES_DIR}" ]]; then
     export AIRFLOW__CORE__DAGS_FOLDER="/files/dags"
@@ -48,3 +49,20 @@ else
     echo "In it to make breeze source the variables automatically for you"
     echo
 fi
+
+
+if [[ -d "${AIRFLOW_BREEZE_CONFIG_DIR}" && \
+    -f "${AIRFLOW_BREEZE_CONFIG_DIR}/${TMUX_CONF_FILE}" ]]; then
+    pushd "${AIRFLOW_BREEZE_CONFIG_DIR}" >/dev/null 2>&1 || exit 1
+    echo
+    echo "Using ${TMUX_CONF_FILE} from ${AIRFLOW_BREEZE_CONFIG_DIR}"
+    echo
+     # shellcheck disable=1090
+    cp "${AIRFLOW_BREEZE_CONFIG_DIR}/${TMUX_CONF_FILE}" ~
+    popd >/dev/null 2>&1 || exit 1
+else
+    echo
+    echo "You can add ${AIRFLOW_BREEZE_CONFIG_DIR} directory and place ${TMUX_CONF_FILE}"
+    echo "In it to make breeze use your local ${TMUX_CONF_FILE} for tmux"
+    echo
+fi


Code review comments:
diff_hunk: @@ -48,3 +49,20 @@ else
     echo "In it to make breeze source the variables automatically for you"
     echo
 fi
+
+
+if [[ -d "${AIRFLOW_BREEZE_CONFIG_DIR}" && \
+    -f "${AIRFLOW_BREEZE_CONFIG_DIR}/${TMUX_CONF_FILE}" ]]; then
+    pushd "${AIRFLOW_BREEZE_CONFIG_DIR}" >/dev/null 2>&1 || exit 1
+    echo
+    echo "Using ${TMUX_CONF_FILE} from ${AIRFLOW_BREEZE_CONFIG_DIR}"
+    echo
+     # shellcheck disable=1090
+    cp "${AIRFLOW_BREEZE_CONFIG_DIR}/${TMUX_CONF_FILE}" ~
path: scripts/in_container/configure_environment.sh
text: @user1:
Would it be possible to `ln -s` instead so changes in the container can be kept?

@user2:
> Would it be possible to `ln -s` instead so changes in the container can be kept?

Good point!

@author:
Thanks for the suggestion @user1.
changes has been done