diff --git a/.gitignore b/.gitignore index 4a48538..d115a80 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.DS_store \ No newline at end of file +.DS_store +.idea/ \ No newline at end of file diff --git a/android-messages.py b/android-messages.py index 82a6f64..c2c599f 100644 --- a/android-messages.py +++ b/android-messages.py @@ -4,7 +4,9 @@ keymap = { - 'new conversation': Key('cmd-alt-c'), + # Collides with spectacle + 'new': Key('cmd-alt-c'), + 'next conversation': Key('ctrl-.'), 'previous conversation': Key('ctrl-,'), 'delete conversation': Key('cmd-alt-r'), diff --git a/bit-bucket.py b/bit-bucket.py index 0388e56..ed74f12 100644 --- a/bit-bucket.py +++ b/bit-bucket.py @@ -4,7 +4,6 @@ keymap = { # All Pages - 'shortcuts': Key('?'), 'left navigation': Key('['), 'site search': Key('/'), @@ -14,8 +13,8 @@ 'next item': Key('j'), 'last item': Key('k'), 'selected': Key('o'), - '[work] dashboard': Key('g d'), - '[bucket] settings': Key('g a'), + 'dashboard': Key('g d'), + 'settings': Key('g a'), 'remove focus': Key('esc'), 'go back': Key('u'), 'right navigation': Key(']'), @@ -25,19 +24,19 @@ # Repository pages (except source) 'create': Key('c r'), - 'import': Key('I r'), + 'import': Key('i r'), 'source': Key('r s'), 'view commits': Key('r c'), 'view branches': Key('r b'), 'pull requests': Key('r p'), 'issues': Key('r i'), 'wiki': Key('r w'), - 'show downloads': Key('r d'), + 'downloads': Key('r d'), 'repo settings': Key('r a'), 'find file': Key('f'), # Repository pages (except source and settings) - 'fork repository': Key('x f'), + 'fork': Key('x f'), 'create branch': Key('x b'), 'compare': Key('x c'), 'create pull request': Key('x p'), diff --git a/finder.py b/finder.py index 86c3d73..0124f7e 100644 --- a/finder.py +++ b/finder.py @@ -1,6 +1,17 @@ -from talon.voice import Key, Context +from talon.voice import Key, Context, Str, press + ctx = Context('Finder', bundle='com.apple.finder') + + +def go_to_path(path): + def path_function(m): + press('cmd-shift-g') + Str(path)(None) + press('return') + return path_function + + ctx.keymap({ '(dupe | duplicate)': Key('cmd-d'), 'trash it': Key('cmd-backspace'), @@ -18,6 +29,15 @@ 'home': Key('shift-cmd-h'), 'iCloud': Key('shift-cmd-i'), 'airdrop': Key('shift-cmd-r'), + 'talon': go_to_path('~/.talon/user'), + 'code': go_to_path('~/code'), + 'pictures': go_to_path('~/Pictures'), + 'music': go_to_path('~/Music'), + 'movies': go_to_path('~/Movies'), + 'dropbox': go_to_path('~/Dropbox'), + 'books': go_to_path('~/Books'), + 'local sites': go_to_path('~/Local Sites'), + 'next level': go_to_path('~/Documents/Client Work/Next Level'), # views 'icon': Key('cmd-1'), @@ -45,7 +65,6 @@ 'open': Key('cmd-down'), '(info | information)': Key('cmd-i'), - # other actions '[toggle] preview': Key('shift-cmd-p'), 'eject': Key('cmd-e'), @@ -56,5 +75,4 @@ 'add to sidebar': Key('ctrl-cmd-t'), 'show package contents': Key('cmd-alt-o'), # 'pathway': Key('cmd-alt-c'), - }) - +}) diff --git a/google-chrome.py b/google-chrome.py index 1d0f76e..482c14b 100644 --- a/google-chrome.py +++ b/google-chrome.py @@ -38,6 +38,7 @@ def focus_address_bar(m): def search(m): press('cmd-m') + press('cmd-shift-.') def scroll_to_top(m): diff --git a/slack.py b/slack.py index 7230e32..44c9bc6 100644 --- a/slack.py +++ b/slack.py @@ -29,8 +29,11 @@ 'directory': Key('cmd-shift-e'), '(starred [items] | stars)': Key('cmd-shift-s'), 'unread [messages]': Key('cmd-j'), + 'top': Key('cmd-up'), + 'bottom': Key('cmd-down'), '(go | undo | toggle) full': Key('ctrl-cmd-f'), + # Messaging 'grab left': Key('shift-up'), 'grab right': Key('shift-down'), diff --git a/std.py b/std.py index 5f2f92e..508c03a 100644 --- a/std.py +++ b/std.py @@ -2,11 +2,12 @@ from talon import ctrl, clip from talon_init import TALON_HOME, TALON_PLUGINS, TALON_USER import string +# from user.utils import parse_word, surround, text, sentence_text, word, parse_words -alpha_alt = 'air bat cap die each fail gone harm sit jury crash look mad near odd pit quest red sun trap urge vest whale box yes zip'.split() -### -alnum = list(zip(alpha_alt, string.ascii_lowercase)) + [(str(i), str(i)) for i in range(0, 10)] +alpha_alt = 'air bat cap die each fail gone harm sit jury crash look mad near odd pit quest red sun trap urge vest ' \ + 'whale box yes zip'.split() +alnum = list(zip(alpha_alt, string.ascii_lowercase)) + [(str(i), str(i)) for i in range(0, 10)] alpha = {} alpha.update(dict(alnum)) alpha.update({'ship %s' % word: letter for word, letter in zip(alpha_alt, string.ascii_uppercase)}) @@ -19,18 +20,18 @@ ] keys = alnum + [(k, k) for k in keys] keys += [ - ('tilde', '`'), - ('comma', ','), - ('dot', '.'), - ('slash', '/'), - ('(semi | semicolon)', ';'), - ('quote', "'"), - ('[left] square', '['), - ('(right | are) square', ']'), - ('backslash', '\\'), - ('minus', '-'), - ('equals', '='), -] + fkeys + ('tilde', '`'), + ('comma', ','), + ('dot', '.'), + ('slash', '/'), + ('(semi | semicolon)', ';'), + ('quote', "'"), + ('[left] square', '['), + ('(right | are) square', ']'), + ('backslash', '\\'), + ('minus', '-'), + ('equals', '='), + ] + fkeys alpha.update({word: Key(key) for word, key in fkeys}) alpha.update({'control %s' % k: Key('ctrl-%s' % v) for k, v in keys}) alpha.update({'control shift %s' % k: Key('ctrl-shift-%s' % v) for k, v in keys}) @@ -50,11 +51,13 @@ # used for auto-spacing punctuation = set('.,-!?') + def parse_word(word): word = str(word).lstrip('\\').split('\\', 1)[0] word = mapping.get(word, word) return word + def join_words(words, sep=' '): out = '' for i, word in enumerate(words): @@ -63,30 +66,38 @@ def join_words(words, sep=' '): out += word return out + def parse_words(m): return list(map(parse_word, m.dgndictation[0]._words)) + def insert(s): Str(s)(None) + def text(m): insert(join_words(parse_words(m)).lower()) + def sentence_text(m): text = join_words(parse_words(m)).lower() insert(text.capitalize()) + def word(m): text = join_words(list(map(parse_word, m.dgnwords[0]._words))) insert(text.lower()) + def surround(by): def func(i, word, last): if i == 0: word = by + word if last: word += by return word + return func + def rot13(i, word, _): out = '' for c in word.lower(): @@ -95,22 +106,55 @@ def rot13(i, word, _): out += c return out + +# formatters = { +# 'dunder': (True, lambda i, word, _: '__%s__' % word if i == 0 else word), +# 'camel': (True, lambda i, word, _: word if i == 0 else word.capitalize()), +# 'snake': (True, lambda i, word, _: word if i == 0 else '_' + word), +# 'smash': (True, lambda i, word, _: word), +# # spinal or kebab? +# 'truck': (True, lambda i, word, _: word if i == 0 else '-' + word), +# # 'sentence': (False, lambda i, word, _: word.capitalize() if i == 0 else word), +# 'title': (False, lambda i, word, _: word.capitalize()), +# 'allcaps': (False, lambda i, word, _: word.upper()), +# 'dubstring': (False, surround('"')), +# 'string': (False, surround("'")), +# 'padded': (False, surround(" ")), +# 'rot-thirteen': (False, rot13), +# } + formatters = { + 'cram': (True, lambda i, word, _: word if i == 0 else word.capitalize()), + 'pathway': (True, lambda i, word, _: word if i == 0 else '/'+word), + 'dotsway': (True, lambda i, word, _: word if i == 0 else '.'+word), + 'yellsmash': (True, lambda i, word, _: word.upper()), + 'yellsnik': (True, lambda i, word, _: word.upper() if i == 0 else '_'+word.upper()), + 'dollcram': (True, lambda i, word, _: '$'+word if i == 0 else word.capitalize()), + 'champ': (True, lambda i, word, _: word.capitalize() if i == 0 else " "+word), + 'lowcram': (True, lambda i, word, _: '@'+word if i == 0 else word.capitalize()), + 'criff': (True, lambda i, word, _: word.capitalize()), + 'criffed': (True, lambda i, word, _: word.capitalize()), + 'yeller': (False, lambda i, word, _: word.upper()), 'dunder': (True, lambda i, word, _: '__%s__' % word if i == 0 else word), 'camel': (True, lambda i, word, _: word if i == 0 else word.capitalize()), 'snake': (True, lambda i, word, _: word if i == 0 else '_'+word), + 'dot': (True, lambda i, word, _: '.'+word if i == 0 else '_'+word), 'smash': (True, lambda i, word, _: word), # spinal or kebab? - 'truck': (True, lambda i, word, _: word if i == 0 else '-'+word), + 'spine': (True, lambda i, word, _: word if i == 0 else '-'+word), # 'sentence': (False, lambda i, word, _: word.capitalize() if i == 0 else word), 'title': (False, lambda i, word, _: word.capitalize()), + 'tridal': (False, lambda i, word, _: word.capitalize()), 'allcaps': (False, lambda i, word, _: word.upper()), 'dubstring': (False, surround('"')), + 'coif': (False, surround('"')), 'string': (False, surround("'")), + 'posh': (False, surround("'")), 'padded': (False, surround(" ")), 'rot-thirteen': (False, rot13), } + def FormatText(m): fmt = [] for w in m._words: @@ -131,7 +175,7 @@ def FormatText(m): word = parse_word(word) for name in reversed(fmt): smash, func = formatters[name] - word = func(i, word, i == len(words)-1) + word = func(i, word, i == len(words) - 1) spaces = spaces and not smash tmp.append(word) words = tmp @@ -141,6 +185,7 @@ def FormatText(m): sep = '' Str(sep.join(words))(None) + ctx = Context('input') keymap = {} keymap.update(alpha) @@ -157,48 +202,29 @@ def FormatText(m): 'tab': Key('tab'), '(backtab | back tab)': Key('shift-tab'), - '(left | lef)': Key('left'), + '(left | lef)': Key('left'), 'right': Key('right'), - 'up': Key('up'), - 'down': Key('down'), + 'up': Key('up'), + 'down': Key('down'), 'puter sleep': Key('ctrl-alt-shift-cmd-s'), 'puter down': Key('ctrl-alt-shift-cmd-d'), 'puter restart': Key('ctrl-alt-shift-cmd-r'), 'about this puter': Key('ctrl-alt-shift-cmd-a'), + # 'exit talent': Key('ctrl-alt-shift-cmd-t'), 'delete': Key('backspace'), 'quit': Key('cmd-q'), 'kill': Key('ctrl-c'), + 'screenshot page': Key('alt-shift-p'), - - # Spectacle - # '(fullscreen | full)': Key('cmd-alt-f'), - # 'snapleft': Key('cmd-alt-left'), - # 'snapright': Key('cmd-alt-right'), - # 'center': Key('alt-cmd-c'), - # # 'left half': Key('alt-cmd-left'), - # # 'right half': Key('alt-cmd-right'), - # 'tippy half': Key('alt-cmd-up'), - # 'flippy half': Key('alt-cmd-down'), - # 'upper left': Key('ctrl-cmd-left'), - # 'lower left': Key('ctrl-shift-cmd-left'), - # 'upper right': Key('ctrl-cmd-right'), - # 'lower right': Key('ctrl-shift-cmd-right'), - # 'next display': Key('ctrl-alt-cmd-right'), - # 'previous left': Key('ctrl-alt-cmd-left'), - # 'next third': Key('ctrl-alt-right'), - # 'previous third': Key('ctrl-alt-left'), - # 'make larger': Key('ctrl-alt-shift-right'), - # 'make smaller': Key('ctrl-alt-shift-left'), - # 'spec undo': Key('alt-cmd-z'), - # 'spec redo': Key('alt-shift-cmd-z'), + # my stuff + 'my e-mail': 'ianmarkind@gmail.com', 'spotlight': Key('cmd-space'), - 'cut': Key('cmd-x'), 'copy': Key('cmd-c'), 'paste': Key('cmd-v'), @@ -229,14 +255,14 @@ def FormatText(m): # Zoom 'zoom in': Key('cmd-+'), 'zoom out': Key('cmd--'), - + '(comment | uncomment)': Key('cmd-/'), 'start': Key('cmd-left'), 'end': Key('cmd-right'), - 'page up': Key('pageup'), + 'page up': Key('pageup'), 'page down': Key('pagedown'), 'jump [right] word': Key('alt-right'), - 'jump left word': Key('alt-left'), + 'jump left word': Key('alt-left'), # Selecting text 'select line': Key('cmd-right cmd-shift-left'), @@ -255,9 +281,9 @@ def FormatText(m): '(bang | exclamation point)': '!', 'dollar [sign]': '$', '(downscore | score)': '_', - '(dubscore | double downscore | behm)': '__', - '(dubscore | double dash | behmdash)': '--', - + '(dubscore | double downscore | behm)': '__', + '(dubscore | double dash | behmdash)': '--', + '(semi | semicolon)': ';', 'colon': ':', '(square | left square [bracket] | bracket)': '[', '(rsquare | are square | right square [bracket])': ']', @@ -349,7 +375,6 @@ def FormatText(m): 'empty dict | braces': '{}', # 'brace': [' else if ()', Key('left')], - # python 'state (def | deaf | deft)': 'def ', 'state else if': 'elif ', @@ -461,5 +486,3 @@ def FormatText(m): }) ctx.keymap(keymap) - -