Path into PS1 prompt is broken (\n) on different lines when it is too long I am using iTerm2 on MacOS Catalina . Here is my PS1 into ~/.bashrc , using a function ps1 :

function ps1 {
        # PROMPT SECTION
        BLUE='\[\033[0;34m\]'
        LIGHT_CYAN='\[\033[1;36m\]'
        DEFAULT='\[\033[0m\]'
        PURPLE='\[\033[0;35m\]'
        LIGHT_PURPLE='\[\033[1;35m\]'
        LIGHT_GREEN='\[\033[0;32m\]'
        PINK='\[\033\[0;31m\]'


        # \! - History number of last command
        # $? - Exit value of last command
        # \t - Exit time of last command
        # \w - Current directory (relative)

PS1="$PURPLE|$DEFAULT$LIGHT_GREEN\u@$DEFAULT$LIGHT_CYAN\h$DEFAULT$PURPLE|$DEFAULT\t$PURPLE|$DEFAULT$LIGHT_PURPLE\w$DEFAULT$PURPLE|$DEFAULT "
}

ps1


The issue happens when I have long path, it seeems to  be broken on second or third line like this :



I tried to increase the number of columns (to 1000) into iTerm2 -&gt; Preferences but it doesn't seem to fix this issue.

I can't see where the error comes from.

Anyone could see what's wrong ? Regards

  fab@astro|13:12:32|~/Phd_2019_2020/Travail_2_faire_varier_Omega_DE_sur_CAMB_et_regarder_si_les_P_k_changent_21_Octobre_2019/Main_Directory_Work/TSAF_lvl_up_Derivatives_15_points_on_Cl_stabilite_Code_is_surel
y_VALIDATED_for_15_points_derivatives_AND_After_trying_to_solve_the_pathologic_zone_1e-5_TO_1e-2_13_Novembre_2019/Test_FAIRE_VARIER_TOUS_LES_PARAMETRES_AVEC_les_2_pas_2e-2_et_1e-1_AVEC_Takabird_SECONDE_TENTATIVE_AVEC_LA_VAR        IATION_de_wde_EN_FLAT_DANS_Camb_launcher_6_DECEMBRE_2019/CAMB_der_3_pts/fortran|
It's a bug related to the old version of bash included in macOS. 

To overcome you can


Switch to zsh (see What are the practical differences between Bash and Zsh?) 
Install a more recent version of bash via Homebrew and use this as your standard shell (see How to use bash as default shell)