French keyboard on macOS, altering the behavior of the tilde ~ key

梦想与她 提交于 2020-06-17 16:20:44

问题


Like most french users, when I want to go to my terminal home, I have to type

cd ~

However, the keyboard requires me to press options + n and then space to disambiguate between me trying to do ñ or ~ for example.

Is there a way to overload this behavior, as I almost never want to use the tilde symbol the way spanish people does ?

Karabiner looked promising but it won't let you define custom mapping. It requires you to chose between a set of predefined ones, online.


回答1:


Ukelele can create a keyboard variation where tilde ~ is not a dead key, probably your best bet if you can get it to launch without hanging. You can always type ñ by holding down the n key for a second. Karabiner-Elements, AppleScript, etc. can only type what your keyboard supports, e.g., these bash commands with Karabiner:

cat > ~/.config/karabiner/assets/complex_modifications/azerty-tilde.json <<.
{"title": "AZERTY tilde",
 "rules": [
   {"description": "AZERTY tilde emits space after dead key ~ (option-n) for French keyboard.
Bug: auto-repeat gets only spaces after the initial tilde.",
    "manipulators": [
      {"type": "basic",
       "from": {"key_code": "n", "modifiers": {"mandatory": ["option"]}},
       "to": [{"key_code": "n", "modifiers": ["option"]},
              {"key_code": "spacebar"}]}]}]}
.

Now the "AZERTY tilde" rule is installed.

Open -a Karabiner-Elements

Pick this menu sequence to enable the "AZERTY tilde" rule:

Karabiner-Elements > Window > Karabiner-Elements Preferences > Complex Modifications > Rules > Add Rule

In the Add rule window, find "AZERTY tilde" on the left and use the corresponding  ⊕ Enable  button on the right. Now every dead-key tilde is followed by a space. The "AZERTY tilde"  ⊕ Remove  button disables it. Tested in Emacs with ns-option-modifier set to none, FireFox, iTerm and Terminal.



来源:https://stackoverflow.com/questions/61038486/french-keyboard-on-macos-altering-the-behavior-of-the-tilde-key

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!