rmvz3
rmvz3

Reputation: 1173

Mac export PS1 doesn't handle escaped commands

I'm just trying to change the terminal prompt in macOS Sierra. Nothing fancy, I just need to know the current path.

In my ~/.bash_profile I'm adding

export PS1="[\w] > "

I know that \w should be replaced by current full path but none of the escape characters seems to work on my Mac. I just get the same string without evaluating, so my prompt looks like

[\w] >

I've tried many different PS1 strings without luck. I also tried using .bashrc instead bash_profile.

Any ideas?

Upvotes: 1

Views: 3329

Answers (2)

Unmesh
Unmesh

Reputation: 637

Run the following command to change your shell to bash (you will be prompted to enter your password). Restart the "Terminal" after that.

chsh -s /bin/bash

Upvotes: 0

Benjamin W.
Benjamin W.

Reputation: 52506

I suspect you're running a shell that doesn't understand the \w escape in the prompt string. If echo $0 returns something other than -bash, you have to use whatever that shell understands:

Upvotes: 3

Related Questions