Package: gen-compose
Compose Key On Macosgen-compose- generatescompose keykeybindings for macos.A compose key (sometimes called multi key) is a key on a computer keyboard that indicates that the following (usually 2 or more) keystrokes trigger the insertion of an alternate character, typically a precomposed character or a symbol.https://en.wikipedia.org/wiki/Compose_keyCompose keys lets you insert complex character by entering multiple characters in a succession:e.g.<compose_key> + d + o + w + nwill insert👇Mac os doesn't come with a compose key feature built-in. However there's a short hack to make it work:Keys can be rebound in mac via~/Library/KeyBindings/DefaultKeyBinding.dictdictionary file.The rebound keys can be chained like compose keys e.g. pressingabcdcan be made to insertAlphaBetaCharlieDadModifier keys cannot be reboundWith these three rules we can replicate compose key and even set it to work with a mod key!Installgen-composecan be installed via python manager with py3.6+ versions:$ pip3 install --user gen-compose
$ gen-compose --help
Usage: gen-compose [OPTIONS] [MAPPINGS]...

  Generate macos rebind file from compose json mapping

Options:
  --key TEXT  key to use as compose key  [default: §]
  -r, --raw   just keymap without prefix
  --help      Show this message and exit.PreconfigFirst lets fix modifier key issue by forcing modifier to be a character. For example to useright_optionskey we need to usekarabiner elementsand remap it to some unused key likenon_us_backslash:Now we have the compose key ready: if we click right_options it should insert§characterHowever we cannot compose anything yet as we have no compose mappings yet. For that we need to modify keybindings dictionary located in~/Library/KeyBindings/DefaultKeyBinding.dict.It's written in some cryptic hard to edit format and here's wheregen-composecomes in and lets you writeyamlfiles instead!UsageCreate yaml mappings file (e.g.mappings/readme.yaml):cat:"(^≗ω≗^)""+1":👍"-1":👎":(":"myfaceissad"This map defines key combinations and texts that will be inserted, e.g.<compose_key><plus><number 1>will insert thumbs up.note: seemappingsdirectory for some built in mappingsUsinggen-composewe generated.dictkeybind file file from our yaml configuration:$gen-composemappings/readme.yaml{"§"={"c"={"a"={"t"=("insertText:","(^≗ω≗^)");};};"+"={"1"=("insertText:","👍");};"-"={"1"=("insertText:","👎");};":"={"("=("insertText:","my face is sad");};};}note: multiple mappings can be used to generate a single keymap:$ gen-compose map1.yaml map2.yamlNow save it directly to keybinds file:$gen-composemappings/readme.yaml>~/Library/KeyBindings/DefaultKeyBinding.dictRestart your programs and type§+1and you'll see👍!Customize your own mapping or see/mappingsfor some existing configurations and have fun!note: Some programs need a hard reboot to take in the map, likekill -9sort of reboot to start working.Using XCompose MappingsLinux's xcompose mappings are supported via experimental conversion:$ gen-compose-convert xcompose --help
Usage: gen-compose-convert xcompose [OPTIONS] [FILES]...

  Convert xcompose file, that follows format like: <Multi_key> <parenleft>
  <period> <1> <parenright>: "⑴"

Options:
  -c, --keep-comments  keep inline comments
  --help               Show this message and exit.For example:$ head mappings/example.compose
<Multi_key> <B> <bar> : "₿" U20BF  # BITCOIN SIGN
...
$ gen-compose-convert xcompose mappings/xcompose.compose --keep-comments > example.yaml
$ cat example.yaml
"B|": "₿"  # BITCOIN SIGN
...Exporting to XComposegen-compose-exportcommand can be used export yaml configuration back to XCompose file:$gen-compose-export--help
Usage:gen-compose-export[OPTIONS]YAMLFILEExport.yamlconfigfilebacktoXComposefilei.e.thisisreverseofgen-compose-convert

Options:--helpShowthismessageandexit.For example:$headmappings/xcompose.yaml"..":"…"# HORIZONTAL ELLIPSIS"v..":"⋮"# VERTICAL ELLIPSIS...$gen-compose-exportmappings/xcompose.yaml>xcompose.compose$headxcompose.compose<Multi_key><period><period>:"…"<Multi_key><v><period><period>:"⋮"<Multi_key><c><period><period>:"⋯"<Multi_key><slash><period><period>:"⋰"<Multi_key><period><backslash><period>:"⋱"<Multi_key><2><period>:"‥"<Multi_key><c><1><period>:"·"<Multi_key><period><slash><period>:"⁒"<Multi_key><ampersand><at>:"⅋"<Multi_key><ampersand><7>:"⁊"...Notes and IssuesThere's no way to really debug this other than trial and error and making sure applications are restarted after every update.When multiple keymaps (egcompose-gen map1.yaml map2.yal) provided they will be joined and updated in order they are provided.Keymap does not allow completely overlapping keys. e.g.eggandeggplantwill break because it's impossible to map two overlapping values as keymap functionality has no timeout (i.e. break if nothing is typed after a second and insertegg, instead it will wait indefinitely for you to finisheggplant)If overlap happenscompose-genwill choose the shorter form and discard the long one.To fix this add end terminator character such as space:egg<space>rather thaneggin your mappings.DefaultKeyBinding.dictmap doesn't work in some popular programs:JetBrain editors such as PyCharm, see:https://youtrack.jetbrains.com/issue/IDEA-127470QT apps such as Qutebrowser, see (and vote):https://bugreports.qt.io/browse/QTBUG-393Related Resourceshttps://github.com/gnarf/osx-compose-keyhttp://lolengine.net/blog/2012/06/17/compose-key-on-os-xhttp://bob.cakebox.net/osxcompose.phphttps://github.com/ttscoff/KeyBindings