Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PS1 env cannot parse on the new mac Catalina

Tags:

shell

macos

ps1

My PS1 variable cannot parsed correctly, it looks like this,

\[\033[01;32m\]\u@\h\[\033[01;34m\] [\w]\[\033[00m\]
\[\033[01;32m\]\u@\h\[\033[01;34m\] [\w]\[\033[00m\]
\[\033[01;32m\]\u@\h\[\033[01;34m\] [\w]\[\033[00m\]mv .bashrc .bash_profile
\[\033[01;32m\]\u@\h\[\033[01;34m\] [\w]\[\033[00m\]source .bash_profile
\[\033[01;32m\]\u@\h\[\033[01;34m\] [\w]\[\033[00m\]
\[\033[01;32m\]\u@\h\[\033[01;34m\] [\w]\[\033[00m\]ls
Applications    Desktop     Documents   Downloads   Google Drive    Library     Movies      Music       Pictures    Public
\[\033[01;32m\]\u@\h\[\033[01;34m\] [\w]\[\033[00m\]vim .bash_profile
\[\033[01;32m\]\u@\h\[\033[01;34m\] [\w]\[\033[00m\]source .bash_profile
\[\e[;31m\][\u@\h \W]$ \[\e[m\]
\[\e[;31m\][\u@\h \W]$ \[\e[m\]
\[\e[;31m\][\u@\h \W]$ \[\e[m\]
\[\e[;31m\][\u@\h \W]$ \[\e[m\]

What is happened? Thanks.

like image 370
Polaris Avatar asked Dec 01 '19 03:12

Polaris


1 Answers

I came across this issue as well with a brand new Catalina machine. New models seem to default to zsh shell, instead of the traditional bash, to change this:

Go to Users & Groups (unlock to make admin changes) right-click on your admin user, Advanced Options..., change Login shell to /bin/bash

After right clicking on user

This will allow you to utilize bash's prompt string parsing for a nicer prompt - as mac has traditionally supported in the past.

like image 111
ElliotM Avatar answered Nov 13 '22 03:11

ElliotM