Tilde not recognized in Mac terminal

2019-03-12 11:09发布

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?

8条回答
叼着烟拽天下
2楼-- · 2019-03-12 11:48

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.

查看更多
小情绪 Triste *
3楼-- · 2019-03-12 11:48

Yep, that's an enye (option-n) not ~ (shift-`)

查看更多
\"骚年 ilove
4楼-- · 2019-03-12 11:57

Try this one:

˜ + <spacebar> 

It's results the tilde you want: ~

The ˜ character's code is 0x02DC and the code that works in bash like shortcut to home directory is 0x07E.

查看更多
Emotional °昔
5楼-- · 2019-03-12 12:00

After changing the keyboard (System Preferences>Keyboard>Input Sources) from 'US International - PC' to 'U.S.', I was able to verify tilde sign (~) works as expected from Terminal.

It looks like in some of the macbook, the keyboard is set to 'US International - PC' instead of 'U.S.'

Compares the different keyboard layouts while pressing SHIFT

查看更多
够拽才男人
6楼-- · 2019-03-12 12:02

I set up KeyRemap4MacBook application and type ~ with shift+escape

setting tilde key to shift escape in KeyRemap4MacBook

查看更多
祖国的老花朵
7楼-- · 2019-03-12 12:05

alt+5 is what you are looking for...

查看更多
登录 后发表回答