Take the 2-minute tour ×
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?

In Terminal it says

Last login: Mon Jan 13 00:00:14 on ttys000
Whatever:~ UserName$ 

Is it possible to show just the current folder and $ sign?

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
add comment

3 Answers 3

up vote 9 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
add comment

Check out this tutorial on how to change your bash prompt. A very short version (only username and no current path): PS1="\u$ "

Result: myusername$ cat something.log

share|improve this answer
    
It works, now the problem is it will not save the new bash prompt. It will show the old one after i shut down my mac. Why? –  DzulFriday May 15 '12 at 2:07
2  
Did you put the variable in the following file: /Users/<yourusername>/.bash_profile? –  timbooo May 15 '12 at 15:34
add comment
echo "export PS1='$ '" >> ~/.bash_profile
. ~/.bash_profile

This will leave just $ as a prompt. If you want to restore the old prompt, you will need to edit .bash_profile to remove that "export ..." line.

share|improve this answer
add comment

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.