From 0ab9c43e73dd6f07b1a39aa65f651c48c4fb0c25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mevl=C3=BCt=20Canvar?= Date: Wed, 6 Jan 2021 00:08:35 +0300 Subject: [PATCH 1/2] initial tilde-switch plugin commit --- plugins/tilde-switch/README.md | 9 ++++++++ plugins/tilde-switch/tilde-switch.plugin.zsh | 22 ++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 plugins/tilde-switch/README.md create mode 100644 plugins/tilde-switch/tilde-switch.plugin.zsh diff --git a/plugins/tilde-switch/README.md b/plugins/tilde-switch/README.md new file mode 100644 index 000000000..08f31fcff --- /dev/null +++ b/plugins/tilde-switch/README.md @@ -0,0 +1,9 @@ +# tilde-switch plugin + +By default, on some non-US keyboards of Macbooks like Swedish and Turkish, tilde key switched with a plus-minus key. So this plugin switches back the `±` key to `~` without needing any third-party tool or service. + +To use it, add `tilde-switch` to the plugins array of your `.zshrc` file: +``` +plugins=(... tilde-switch) +``` + diff --git a/plugins/tilde-switch/tilde-switch.plugin.zsh b/plugins/tilde-switch/tilde-switch.plugin.zsh new file mode 100644 index 000000000..9705a159d --- /dev/null +++ b/plugins/tilde-switch/tilde-switch.plugin.zsh @@ -0,0 +1,22 @@ +#!/usr/bin/env zsh + +# +# tilde-switch-zsh +# +# This key binding plugin gets tilde key back on MacOS +# Swithes back ± key to ~ +# +# Copyright(c) 2021 Mevlut Canvar +# MIT Licensed +# + +# +# Mevlüt Canvar +# GitHub: https://github.com/mcanvar +# Twitter: https://twitter.com/mevlutcanvar +# + +# +# This solution taken from here: https://apple.stackexchange.com/a/353941 +# +hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000035,"HIDKeyboardModifierMappingDst":0x700000064},{"HIDKeyboardModifierMappingSrc":0x700000064,"HIDKeyboardModifierMappingDst":0x700000035}]}' > /dev/null From 329fae95c14337aada635431381baa469dcd108f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mevl=C3=BCt=20Canvar?= Date: Wed, 6 Jan 2021 02:01:50 +0300 Subject: [PATCH 2/2] refactors tilde-switch plugin --- plugins/tilde-switch/tilde-switch.plugin.zsh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/plugins/tilde-switch/tilde-switch.plugin.zsh b/plugins/tilde-switch/tilde-switch.plugin.zsh index 9705a159d..60587877b 100644 --- a/plugins/tilde-switch/tilde-switch.plugin.zsh +++ b/plugins/tilde-switch/tilde-switch.plugin.zsh @@ -19,4 +19,21 @@ # # This solution taken from here: https://apple.stackexchange.com/a/353941 # -hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000035,"HIDKeyboardModifierMappingDst":0x700000064},{"HIDKeyboardModifierMappingSrc":0x700000064,"HIDKeyboardModifierMappingDst":0x700000035}]}' > /dev/null + +MAPPING=$(cat < /dev/null