init commit
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
import os
|
||||
|
||||
from talon import Context, actions, ui
|
||||
from talon.mac import applescript
|
||||
|
||||
ctx = Context()
|
||||
ctx.matches = r"""
|
||||
app: finder
|
||||
"""
|
||||
directories_to_remap = {"": "/Volumes"}
|
||||
directories_to_exclude = {}
|
||||
|
||||
|
||||
@ctx.action_class("user")
|
||||
class UserActions:
|
||||
def file_manager_open_parent():
|
||||
actions.key("cmd-up")
|
||||
|
||||
def file_manager_current_path():
|
||||
title = ui.active_window().title
|
||||
|
||||
if "~" in title:
|
||||
title = os.path.expanduser(title)
|
||||
|
||||
if title in directories_to_remap:
|
||||
title = directories_to_remap[title]
|
||||
|
||||
if title in directories_to_exclude:
|
||||
title = ""
|
||||
|
||||
return title
|
||||
|
||||
def file_manager_terminal_here():
|
||||
applescript.run(
|
||||
r"""
|
||||
tell application "Finder"
|
||||
set myWin to window 1
|
||||
set thePath to (quoted form of POSIX path of (target of myWin as alias))
|
||||
tell application "Terminal"
|
||||
activate
|
||||
tell window 1
|
||||
do script "cd " & thePath
|
||||
end tell
|
||||
end tell
|
||||
end tell"""
|
||||
)
|
||||
|
||||
def file_manager_show_properties():
|
||||
"""Shows the properties for the file"""
|
||||
actions.key("cmd-i")
|
||||
|
||||
def file_manager_open_directory(path: str):
|
||||
"""opens the directory that's already visible in the view"""
|
||||
actions.key("cmd-shift-g")
|
||||
actions.sleep("50ms")
|
||||
actions.insert(path)
|
||||
actions.key("enter")
|
||||
|
||||
def file_manager_select_directory(path: str):
|
||||
"""selects the directory"""
|
||||
actions.insert(path)
|
||||
|
||||
def file_manager_new_folder(name: str):
|
||||
"""Creates a new folder in a gui filemanager or inserts the command to do so for terminals"""
|
||||
actions.key("cmd-shift-n")
|
||||
actions.insert(name)
|
||||
|
||||
def file_manager_open_file(path: str):
|
||||
"""opens the file"""
|
||||
actions.key("home")
|
||||
actions.insert(path)
|
||||
actions.key("cmd-o")
|
||||
|
||||
def file_manager_select_file(path: str):
|
||||
"""selects the file"""
|
||||
actions.key("home")
|
||||
actions.insert(path)
|
||||
|
||||
def address_focus():
|
||||
actions.key("cmd-shift-g")
|
||||
|
||||
def address_copy_address():
|
||||
actions.key("alt-cmd-c")
|
||||
|
||||
def address_navigate(address: str):
|
||||
actions.user.file_manager_open_directory(address)
|
||||
@@ -0,0 +1,29 @@
|
||||
os: mac
|
||||
app: finder
|
||||
-
|
||||
tag(): user.address
|
||||
tag(): user.file_manager
|
||||
tag(): user.navigation
|
||||
tag(): user.tabs
|
||||
preferences: key(cmd-,)
|
||||
options: key(cmd-j)
|
||||
search: key(cmd-alt-f)
|
||||
|
||||
# bit of a mouthful, but it's probably not the kind of thing you'd be saying frequently
|
||||
sort by none: key(ctrl-alt-cmd-0)
|
||||
sort by name: key(ctrl-alt-cmd-1)
|
||||
sort by kind: key(ctrl-alt-cmd-2)
|
||||
sort by date opened: key(ctrl-alt-cmd-3)
|
||||
sort by date added: key(ctrl-alt-cmd-4)
|
||||
sort by date modified: key(ctrl-alt-cmd-5)
|
||||
sort by size: key(ctrl-alt-cmd-6)
|
||||
|
||||
icon view: key(cmd-1)
|
||||
column view: key(cmd-3)
|
||||
list view: key(cmd-2)
|
||||
gallery view: key(cmd-4)
|
||||
|
||||
trash it: key(cmd-backspace)
|
||||
|
||||
hide [finder]: key(cmd-h)
|
||||
hide others: app.window_hide_others()
|
||||
Reference in New Issue
Block a user