init commit
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
import os
|
||||
|
||||
from talon import Context, actions, ui
|
||||
|
||||
# TODO: fit this to terminal.py
|
||||
|
||||
ctx = Context()
|
||||
ctx.matches = r"""
|
||||
app: apple_terminal
|
||||
"""
|
||||
directories_to_remap = {}
|
||||
directories_to_exclude = {}
|
||||
|
||||
|
||||
@ctx.action_class("edit")
|
||||
class EditActions:
|
||||
def delete_line():
|
||||
actions.key("ctrl-u")
|
||||
|
||||
|
||||
@ctx.action_class("user")
|
||||
class UserActions:
|
||||
def file_manager_current_path():
|
||||
title = ui.active_window().title
|
||||
|
||||
# take the first split for the zsh-based terminal
|
||||
if " — " in title:
|
||||
title = title.split(" — ")[0]
|
||||
|
||||
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 = None
|
||||
|
||||
return title
|
||||
|
||||
def file_manager_show_properties():
|
||||
"""Shows the properties for the file"""
|
||||
|
||||
def file_manager_open_directory(path: str):
|
||||
"""opens the directory that's already visible in the view"""
|
||||
actions.insert("cd ")
|
||||
path = f'"{path}"'
|
||||
actions.insert(path)
|
||||
actions.key("enter")
|
||||
|
||||
# jtk - refresh title isn't necessary since the apple terminal does it for us
|
||||
# actions.user.file_manager_refresh_title()
|
||||
|
||||
def file_manager_open_parent():
|
||||
actions.insert("cd ..")
|
||||
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"""
|
||||
name = f'"{name}"'
|
||||
|
||||
actions.insert("mkdir " + name)
|
||||
|
||||
def file_manager_open_file(path: str):
|
||||
"""opens the file"""
|
||||
actions.insert(path)
|
||||
actions.key("enter")
|
||||
|
||||
def file_manager_select_file(path: str):
|
||||
"""selects the file"""
|
||||
actions.insert(path)
|
||||
|
||||
def file_manager_refresh_title():
|
||||
return
|
||||
|
||||
|
||||
@ctx.action_class("app")
|
||||
class app_actions:
|
||||
# other tab functions should already be implemented in
|
||||
# code/platforms/mac/app.py
|
||||
|
||||
def tab_previous():
|
||||
actions.key("ctrl-shift-tab")
|
||||
|
||||
def tab_next():
|
||||
actions.key("ctrl-tab")
|
||||
@@ -0,0 +1,25 @@
|
||||
app: apple_terminal
|
||||
-
|
||||
# makes the commands in terminal.talon available
|
||||
tag(): terminal
|
||||
|
||||
# use readline keybindings for various editing commands
|
||||
tag(): user.readline
|
||||
|
||||
# activates the implementation of the commands/functions in terminal.talon
|
||||
tag(): user.generic_unix_shell
|
||||
|
||||
# makes commands for certain applications available
|
||||
# you can deactivate them if you do not use the application
|
||||
tag(): user.git
|
||||
tag(): user.anaconda
|
||||
tag(): user.kubectl
|
||||
|
||||
# TODO: explain
|
||||
tag(): user.tabs
|
||||
tag(): user.file_manager
|
||||
|
||||
suspend: key(ctrl-z)
|
||||
resume:
|
||||
insert("fg")
|
||||
key(enter)
|
||||
Reference in New Issue
Block a user