### .tmux.conf bind-key v command-prompt -p "enter digraph:" "set-buffer \"%%\"; save-buffer /tmp/tmux-input; delete-buffer; if-shell '/home/username/bin/digraph.py < /tmp/tmux-input > /tmp/tmux-output' 'load-buffer /tmp/tmux-output; paste-buffer -d; run-shell \"rm /tmp/tmux-output /tmp/tmux-input\"'" ### digraph.py [python] #!/usr/bin/python import logging import os.path import sys import unicodedata logfile = os.path.join(os.path.dirname(__file__), 'exceptions.log') logging.basicConfig(filename=logfile) COMBINE_MAP = { "`": u'\u0300', "!": u'\u0300', "'": u'\u0301', '"': u'\u0301', "^": u'\u0302', "~": u'\u0303', "-": u'\u0304', ":": u'\u0308', } REPLACE = { "...": u'\N{HORIZONTAL ELLIPSIS}', "``": u'\N{LEFT DOUBLE QUOTATION MARK}', "''": u'\N{RIGHT DOUBLE QUOTATION MARK}', "<3": u'\N{BLACK HEART SUIT}', "--": u'\N{EM DASH}', "AE": u'\N{LATIN CAPITAL LETTER AE}', "ae": u'\N{LATIN SMALL LETTER AE}', "s": u'\N{LATIN SMALL LETTER LONG S}', "ss": u'\N{LATIN SMALL LETTER SHARP S}', } def main(value): if value.startswith('U+'): value = value[2:] sys.stdout.write(unichr(int(value, 16)).encode('utf8')) return if value in REPLACE: sys.stdout.write(REPLACE[value].encode('utf8')) return if len(value) != 2: raise Exception("invalid value: " + value) if value[1] in COMBINE_MAP: s = value[0].decode('ascii') + COMBINE_MAP[value[1]] s = unicodedata.normalize('NFC', s) sys.stdout.write(s.encode('utf8')) return raise Exception("invalid value: " + value) if __name__ == '__main__': try: main(sys.stdin.read()) except Exception, e: logging.exception('blargh') raise