Create ~/.config/karabiner/line.json
as:
{
"title": "Line-related mappings",
"rules": [
{
"description": "Home to Cmd+Left: Move to line start",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "home",
"modifiers": {
"optional": [
"caps_lock"
]
}
},
"to": [
{
"key_code": "left_arrow",
"modifiers": "command"
}
]
}
]
},
{
"description": "Shift+Home to Shift+Cmd+Left: Select to line start",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "home",
"modifiers": {
"mandatory": [
"shift"
],
"optional": [
"caps_lock"
]
}
},
"to": [
{
"key_code": "left_arrow",
"modifiers": [
"shift",
"command"
]
}
]
}
]
},
{
"description": "End to Cmd+Right: Move to line end",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "end",
"modifiers": {
"optional": [
"caps_lock"
]
}
},
"to": [
{
"key_code": "right_arrow",
"modifiers": "command"
}
]
}
]
},
{
"description": "Shift+End to Shift+Cmd+Right: Select to line end",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "end",
"modifiers": {
"mandatory": [
"shift"
],
"optional": [
"caps_lock"
]
}
},
"to": [
{
"key_code": "right_arrow",
"modifiers": [
"shift",
"command"
]
}
]
}
]
}
]
}
Then in Karabiner, go to Preferences -> Complex Modifications -> Add Rules -> Enable All.
The above and others can be found in https://github.com/noel-yap/karabiner.