Save bash profile

How can I permanently save the bash profile? (PS+1) I tried to save it on my mac. But as soon as I open the terminal, the settings are gone.
https://www.codecademy.com/paths/web-development/tracks/learn-the-command-line/modules/learn-the-command-line-environment-u/lessons/environment/exercises/ps1

Hi @remogirard7746549799,

In your home directory, there’s a file called .profile (on Mac) or .bash_profile / .bashrc (on Linux). Open that file in a text editor and add a line at the bottom with what you want your prompt to be. For example, if you want a minimal prompt:

PS1="$ " 

Here’s my prompt, by the way. It shows the current time, then my username, then which directory I’m in, and then the standard dollar sign prompt (items like \033 just sets the color so the prompt isn’t all white text).

\[\e]0;\u@\h: \w\a\][$(date +%H:%M)] ${debian_chroot:+($demian_chroot)}\[\033[01;32m\]\u\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ 

# example prompts:
[12:30] zeke:~$ 
[12:30] zeke:/usr/bin$ 
2 Likes

Hi zystvan,
thank you very much for your reply. I tried it with both files.

nano ~/.bash_profile
nano ~/.profile
export PS1=">> "

and

PS1=">> "

activated with source

It was working until I closed the terminal. Wen I re-opened it, the setting were gone and the files were still there.

@remogirard7746549799 I don’t have a Mac to test with unfortunately, but I found this article which says Macs are no longer using the Bash shell which may be why it didn’t work. Try doing the same thing as before, but this time editing ~/.zshrc (same purpose as the other files, just for the zsh shell).

1 Like

@zystvan ~/.zshrc works, thank you very much! Instead of export PS1=">> " I had to write export PROMPT=">> "

1 Like