I have this weird situation on my Mac running OSX Lion where the ~ (tilda) does not go to my user directory. Instead when I type "cd ˜", I get:
-bash: cd: ˜: No such file or directory
Any advice on how to fix this?
There are several characters like a tilde, and yours ˜
is not the one for the homedir ~
(close together: ˜
vs ~
).
The other answers are correct in that you are not typing the regular tilde character but are using the small tilde character. What the other answers do not explain though is why when you type tilde you are getting the small tilde and not the large tilde.
The same problem plagued me for some time. I found the problem was I was using the 'US - International' key mapping. Try changing it in System preferences > Language and Text > Input Sources. With that keyboard selected you need to type the tilde and then hit the space bar to see it change from small tilde to regular tilde.
I've run into a related issue a couple of times that may have prompted the question: bash doesn't do tilde expansion on quoted filepaths (which you might use if you have spaces in the path). For example, cd "~/Documents/My Project"
gets you the same error originally posted. The trick is to leave the tilde and the first slash outside the quote: cd ~/"Documents/My Project"
works just fine.
As @Venkat Ganesh mentioned, the simple answer to what people are asking is if you're on osx, check to make sure your keyboard didn't get changed to International PC. Once you change it back to US, it resolves the problem. menu bar showing correct US keyboard layout chosen
Yep, that's an enye (option-n) not ~ (shift-`)