What is the quickest and/or easiest way to infrequently type non-KeyLayout provided characters?
I've recently been writing a lot of documentation and would love to be able to type native superscript characters (⁰, ¹, ², ³, ⁴, ⁵) to call out caveats/annotations. The writing environment I'm in does not support markup such as <sup>
or LaTeX-like ^1 ^2 ^3 ^4 ^5
.
My current solution for inserting these characters is to;
- Permanently enable the "input menu in menu bar" in Keyboard.prefPane -> Input Sources
- Mouse over to the input menu icon, click it, then 'Show Character Viewer'.
- Once the Character Viewer is shown, mouse to the character search box, and type either the number to superscript, or literally enter the word 'superscript' which will helpfully give me 0-9 that I can quickly use if necessary.
How can I shorten the time necessary to input these characters?
I had thought that the command + control + space (⌘^␣) picker was emoji-only, boy was I mistaken. Or perhaps it's changed since I last looked inevitably 1-3 releases of macOS ago?
This is absolutely the fastest way to enter any character, provided it's unicode name isn't overly esoteric.
Set up text replacements for your characters in system preferences/keyboard/text/replace with
I have created an Alfred workflow which runs the script filter below. The script filter is connected to a "Copy to Clipboard" action where the "Automatically paste to front most app" option is selected.
awk 'FILENAME==ARGV[1]{a[tolower($0)];next}{for(i in a)if(!index(tolower($0),i))next}1' <(printf %s\\n {query}) unicode|sed 's/&/\&/g;s/</\</g;s/>/\>/g;s/"/\"/g'|awk -F\; '{print"<item><arg>"$1"</arg><title>"$1,$2,$3"</title><icon></icon></item>"}'|echo "<?xml version='1.0'?><items>$(cat)</items></xml>"
The unicode
file contains the output of the command below. \U
and \u
were added in Bash 4.2.
curl www.unicode.org/Public/UNIDATA/UnicodeData.txt|while read l;do [[ ${l#*;} != @(<|SEMICOLON;)* ]]&&printf \\U$(printf %08d $((0x${l%%;*})));printf ';%s\n' "$l";done|cut -d\; -f-3
This is what the workflow looks like:
I also use the ug
function below to search for Unicode characters in a shell. ~/f/unicodedata
is a version of the UnicodeData.txt
file which includes a field for the literal character at the start of each line. ga
prints the lines of STDIN which contain each argument as a substring.
ga(){ awk 'FILENAME==ARGV[1]{a[tolower($0)];next}{for(i in a)if(!index(tolower($0),i))next}1' <(printf %s\\n "$@") -;}
ug(){ ga "$@"<~/f/unicodedata;}
Example output:
$ ug superscript
²;00B2;SUPERSCRIPT TWO;No;0;EN;<super> 0032;;2;2;N;SUPERSCRIPT DIGIT TWO;;;;
³;00B3;SUPERSCRIPT THREE;No;0;EN;<super> 0033;;3;3;N;SUPERSCRIPT DIGIT THREE;;;;
¹;00B9;SUPERSCRIPT ONE;No;0;EN;<super> 0031;;1;1;N;SUPERSCRIPT DIGIT ONE;;;;
ٰ;0670;ARABIC LETTER SUPERSCRIPT ALEF;Mn;35;NSM;;;;;N;ARABIC ALEF ABOVE;;;;
ܑ;0711;SYRIAC LETTER SUPERSCRIPT ALAPH;Mn;36;NSM;;;;;N;;;;;
⁰;2070;SUPERSCRIPT ZERO;No;0;EN;<super> 0030;;0;0;N;SUPERSCRIPT DIGIT ZERO;;;;
ⁱ;2071;SUPERSCRIPT LATIN SMALL LETTER I;Lm;0;L;<super> 0069;;;;N;;;;;
⁴;2074;SUPERSCRIPT FOUR;No;0;EN;<super> 0034;;4;4;N;SUPERSCRIPT DIGIT FOUR;;;;
⁵;2075;SUPERSCRIPT FIVE;No;0;EN;<super> 0035;;5;5;N;SUPERSCRIPT DIGIT FIVE;;;;
⁶;2076;SUPERSCRIPT SIX;No;0;EN;<super> 0036;;6;6;N;SUPERSCRIPT DIGIT SIX;;;;
⁷;2077;SUPERSCRIPT SEVEN;No;0;EN;<super> 0037;;7;7;N;SUPERSCRIPT DIGIT SEVEN;;;;
⁸;2078;SUPERSCRIPT EIGHT;No;0;EN;<super> 0038;;8;8;N;SUPERSCRIPT DIGIT EIGHT;;;;
⁹;2079;SUPERSCRIPT NINE;No;0;EN;<super> 0039;;9;9;N;SUPERSCRIPT DIGIT NINE;;;;
⁺;207A;SUPERSCRIPT PLUS SIGN;Sm;0;ES;<super> 002B;;;;N;;;;;
⁻;207B;SUPERSCRIPT MINUS;Sm;0;ES;<super> 2212;;;;N;SUPERSCRIPT HYPHEN-MINUS;;;;
⁼;207C;SUPERSCRIPT EQUALS SIGN;Sm;0;ON;<super> 003D;;;;N;;;;;
⁽;207D;SUPERSCRIPT LEFT PARENTHESIS;Ps;0;ON;<super> 0028;;;;Y;SUPERSCRIPT OPENING PARENTHESIS;;;;
⁾;207E;SUPERSCRIPT RIGHT PARENTHESIS;Pe;0;ON;<super> 0029;;;;Y;SUPERSCRIPT CLOSING PARENTHESIS;;;;
ⁿ;207F;SUPERSCRIPT LATIN SMALL LETTER N;Lm;0;L;<super> 006E;;;;N;;;;;
ﱛ;FC5B;ARABIC LIGATURE THAL WITH SUPERSCRIPT ALEF ISOLATED FORM;Lo;0;AL;<isolated> 0630 0670;;;;N;;;;;
ﱜ;FC5C;ARABIC LIGATURE REH WITH SUPERSCRIPT ALEF ISOLATED FORM;Lo;0;AL;<isolated> 0631 0670;;;;N;;;;;
ﱝ;FC5D;ARABIC LIGATURE ALEF MAKSURA WITH SUPERSCRIPT ALEF ISOLATED FORM;Lo;0;AL;<isolated> 0649 0670;;;;N;;;;;
ﱣ;FC63;ARABIC LIGATURE SHADDA WITH SUPERSCRIPT ALEF ISOLATED FORM;Lo;0;AL;<isolated> 0020 0651 0670;;;;N;;;;;
ﲐ;FC90;ARABIC LIGATURE ALEF MAKSURA WITH SUPERSCRIPT ALEF FINAL FORM;Lo;0;AL;<final> 0649 0670;;;;N;;;;;
ﳙ;FCD9;ARABIC LIGATURE HEH WITH SUPERSCRIPT ALEF INITIAL FORM;Lo;0;AL;<initial> 0647 0670;;;;N;;;;;
$ ug superscript paren
⁽;207D;SUPERSCRIPT LEFT PARENTHESIS;Ps;0;ON;<super> 0028;;;;Y;SUPERSCRIPT OPENING PARENTHESIS;;;;
⁾;207E;SUPERSCRIPT RIGHT PARENTHESIS;Pe;0;ON;<super> 0029;;;;Y;SUPERSCRIPT CLOSING PARENTHESIS;;;;