Tell me more ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

How can I hide username and computer in terminal command prompt? Is it possible to show current folder and $ sign?

enter image description here

share|improve this question
1  
What do you mean by show current folder? The current folder is already shown after the :. BTW: I've changed the computer name in System Preferences -> Sharing to MBP. Now my login prompt is very short: mbp:~ matt$ – gentmatt Dec 29 '11 at 7:27

1 Answer

up vote 6 down vote accepted

Change your prompt in your ~/.bashrc file. The example you asked for would be:

export PS1="\W \$"

It would result in the current folder you're in being shown plus a $ for the regular prompt and a # if you're root. Check out this guide for more examples of what you could show in your prompt.

share|improve this answer
I have two questions since I have not that much experience working in the terminal :). 1) Why do you write ~/.bashrc? I found this file located at /private/bashrc. 2) I did not manage to edit the file because it is locked. I've tried changing permissions without success. – gentmatt Dec 29 '11 at 7:18
1  
/etc/bashrc is the global file for all users, ~/.bashrcis your own. Definitions in your own overwrite whatever is defined in /etc/bashrc. – patrix Dec 29 '11 at 7:37
1  
bashrc files are your bash resource files. Where you can customize the prompt, set aliases, export variables. Things of that nature. Like patrix said, the /etc/bashrc and the /private/bashrc files have system-wide resources. So somewhere in the /etc/bashrc is an export PS1 and if you edit your own bashrc file which is located at ~/.bashrc and export your own PS1 then on your account the command prompt will be different. If you want it changed for all users you have to edit the /etc/bashrc with a sudo command. – CaldwellYSR Dec 29 '11 at 17:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.