I am new to the Mac OSX environment, and was programming in C using the terminal. To change the current directory, I used the command cd ..
to go one level up. However, this had a weird effect on the terminal. A clear screen on my mac terminal used to show this path always-
manishs-mbp:manishgiri$
However, since the time I did cd ..
(to go one level up), the current pathway of the terminal has changed to:
manishs-mbp:~ manishgiri$
As you can see, there is a tilde now in the pathname. On reading about it, it looks like this tilde is used to represent the home directory in mac OS. However, I would like to get rid of it, as it was earlier.
Could you please provide a way to do that? Any help would be highly appreciated.
Thank You.
EDIT- Adding more information
I tried to think of it, and realized that cd ..
would have taken me one level up. So, I entered pwd
in the terminal to see the current pathway (this is with the tilde situation), and got this-
manishs-mbp:~ manishgiri$ pwd
/Users/manishgiri
Maybe the tilde appears because I am now by default in the /Users(Home) folder. If that's the case, then how do I revert it back to the previous settings to get rid of the tilde?
Best Answer
In virtually all modern Unix shells,
~
is shorthand for your home directory. On OS X, this expands to/Users/accountname
, in most Linuxes it will be/home/accountname
.The shell you are using (presumably BASH) has its prompt configured to show the current working directory's basename. For instance, if you were to
cd Downloads
, you'll likely see your prompt change to:manishs-mbp:Downloads manishgiri$
If you don't want to see your current directory in your BASH prompt, you'll need to edit your prompt. You can see your current prompt configuration by running:
echo $PS1
You'll likely get a response of:
\h:\W \u\$
The
\W
indicates the Basename of your current directory (e.g.~
orDownloads
), you need to get that out of the prompt.At the most basic, to remove the path just run:
PS1="\h \u\$"
If you want the change to be permanent, you'll need to change/create the PS1 variable declaration in your shell's config file (i.e.
.bashrc
). You'll likely want to read the BASH manual pages or spend some time with a search engine if you want more information on BASH prompt customization.That said, if you're new to the terminal, I suggest leaving it as-is. It's actually quite helpful to have your working directory displayed in your prompt and saves you from having to constantly run
pwd
. To each their own though.EDIT: Maybe I'm overthinking it and you just want a simple (possibly hacky) way to make your prompt not have the working directory basename. If so:
echo 'PS1="\h:\u\$" >> ~/.bashrc
then open a new Terminal window.