diff --git a/.bashrc-reit b/.bashrc-reit
index 3ab62c5a456b237f224d05f882b8fe201889c28a..c22260406d722ecef87ad97dd33c9ff3394cbf75 100644
--- a/.bashrc-reit
+++ b/.bashrc-reit
@@ -1,3 +1,9 @@
+# Check if the shell is interactive loading settings
+if [[ "$-" != *i* ]]; then
+    # Skip setup for non-interactive shells
+    return
+fi
+
 alias reit='echo "Hi, from the Research Engineering and Infrastructure Team!!!"'
 alias reit-update='wget https://gitlab.ewi.tudelft.nl/reit/shell-config/-/raw/main/.bashrc-reit?ref_type=heads -O ~/.bashrc-reit'
 
@@ -47,27 +53,22 @@ alias docker-ls='sudo docker container ls'
 alias docker-prune='sudo docker rm $(sudo docker images -q) -f && sudo docker system prune -f'
 
 # History
-# Append to the history file, don't overwrite it
+## Append to the history file, don't overwrite it
 shopt -s histappend
-
-
-# Check if the shell is interactive before setting up line editing
-if [[ -n "$PS1" ]]; then
-    # Search history configuration
-    # Configure key bindings for history search backward and forward
-    bind '"\e[A": history-search-backward'   # Up arrow key
-    bind '"\e[B": history-search-forward'    # Down arrow key
-    bind '"\eOA": history-search-backward'   # Up arrow key in some terminals
-    bind '"\eOB": history-search-forward'    # Down arrow key in some terminals
-    bind '"^E" end-of-line'                  # Ctrl+E for end of line
-    bind '"^A" start-of-line'                # Ctrl+A for start of line
-fi
-
 HISTSIZE=100000                                # Maximum number of lines kept in memory for the history list
 HISTFILESIZE=100000                            # Maximum number of lines saved in the history file
 export HISTIGNORE="ll:ls:la:cd*:[bf]g*:exit"   # List of patterns to ignore in history
 export HISTCONTROL=erasedups                   # Ignore duplicates and leading/trailing whitespace when adding to history
 
+# Search history configuration
+## Configure key bindings for history search backward and forward
+bind '"\e[A": history-search-backward'   # Up arrow key
+bind '"\e[B": history-search-forward'    # Down arrow key
+bind '"\eOA": history-search-backward'   # Up arrow key in some terminals
+bind '"\eOB": history-search-forward'    # Down arrow key in some terminals
+bind '"^E" end-of-line'                  # Ctrl+E for end of line
+bind '"^A" start-of-line'                # Ctrl+A for start of line
+
 # Functions
 ## Extract archives
 extract () {