Is there a way to hide Terminal.app's credentials (prompt text)?
Solution 1:
What you're after is a custom bash prompt.
For just displaying the folder name, add this to your ~/.bashrc
file:
export PS1="[\w]$"
This is what it will look like (your home directory is shortened to tilde):
[~]$cd / [/]$cd /usr/bin/ [/usr/bin]$
For an excellent overview and a list of the other available escape sequences, check out the following article: How to: Change / Setup bash custom prompt (PS1). It is a Linux tutorial but it works in bash on Mac as well.
Solution 2:
As a general note:
The bash session started by Terminal.app is usually a login session. (You will see the difference as the login session will tell you about your last login on startup.) This can be changed in the preferences where you can choose between /usr/bin/login
and a custom command.
Login sessions don’t usually execute the scripts in ~/.bashrc
but look for /etc/profile
, ~/.bash_profile
, ~/.bash_login
, and ~/.profile
. (See man bash
.) However, /etc/profile
will also call /etc/bashrc
, so that the changing this file gave the appropriate results.
To get consistency over login and non-login shells, one usually changes ~/.profile
to also execute the ~/.bashrc
file and includes all changes for login and non-login shells to the latter.