forked from talonhub/community
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindows_terminal.py
177 lines (139 loc) · 5.5 KB
/
windows_terminal.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import os
from talon import Context, Module, actions, ui
ctx = Context()
mod = Module()
ctx.matches = r"""
app: windows_terminal
"""
user_path = os.path.expanduser("~")
directories_to_remap = {}
directories_to_exclude = {}
@ctx.action_class("app")
class AppActions:
def tab_close():
actions.key("ctrl-shift-w")
def tab_open():
actions.key("ctrl-shift-t")
@ctx.action_class("edit")
class EditActions:
def paste():
actions.key("ctrl-shift-v")
def copy():
actions.key("ctrl-shift-c")
def find(text: str = None):
actions.key("ctrl-shift-f")
if text:
actions.insert(text)
@ctx.action_class("user")
class UserActions:
def file_manager_current_path():
path = ui.active_window().title
path = (
path.replace("Administrator: ", "")
.replace("Windows PowerShell: ", "")
.replace("Command Prompt: ", "")
)
if path in directories_to_remap:
path = directories_to_remap[path]
if path in directories_to_exclude:
path = ""
return path
# def file_manager_terminal_here():
# actions.key("ctrl-l")
# actions.insert("cmd.exe")
# actions.key("enter")
# def file_manager_show_properties():
# """Shows the properties for the file"""
# actions.key("alt-enter")
def file_manager_open_directory(path: str):
"""opens the directory that's already visible in the view"""
actions.insert(f'cd "{path}"')
actions.key("enter")
actions.user.file_manager_refresh_title()
def file_manager_select_directory(path: str):
"""selects the directory"""
actions.insert(f'"{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.insert(f'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_open_volume(volume: str):
"""file_manager_open_volume"""
actions.user.file_manager_open_directory(volume)
actions.user.file_manager_refresh_title()
def tab_jump(number: int):
actions.key(f"ctrl-alt-{number}")
# user.splits implementation:
def split_window_right():
"""Move active tab to right split"""
# TODO: decide whether this notification is good style
actions.app.notify(
'"Split right" is not possible in windows terminal without special configuration. Use "split vertically" instead.'
)
def split_window_left():
"""Move active tab to left split"""
# TODO: decide whether this notification is good style
actions.app.notify(
'"Split left" is not possible in windows terminal without special configuration. Use "split vertically" instead.'
)
def split_window_down():
"""Move active tab to lower split"""
# TODO: decide whether this notification is good style
actions.app.notify(
'"Split down" is not possible in windows terminal without special configuration. Use "split horizontally" instead.'
)
def split_window_up():
"""Move active tab to upper split"""
# TODO: decide whether this notification is good style
actions.app.notify(
'"Split up" is not possible in windows terminal without special configuration. Use "split horizontally" instead.'
)
def split_window_vertically():
"""Splits window vertically"""
actions.key("shift-alt-plus")
def split_window_horizontally():
"""Splits window horizontally"""
actions.key("shift-alt-minus")
def split_flip():
"""Flips the orietation of the active split"""
# TODO: decide whether this notification is good style
actions.app.notify(
'"Split flip" is not possible in windows terminal in default configuration.'
)
def split_window():
"""Splits the window"""
# in this implementation an alias for split vertically
actions.key("shift-alt-plus")
def split_clear():
"""Clears the current split"""
# also closes tab, because shortcut is the same
# and closing a split does mean something differnent that in a code editor like vs code
actions.key("ctrl-shift-w")
def split_clear_all():
"""Clears all splits"""
# TODO: decide whether to implement it at all since it either doesn't makes sense or closes the window/whole tab
def split_next():
"""Goes to next split"""
# TODO: decide whether this notification is good style
actions.app.notify(
'"Split next" is not possible in windows terminal without special configuration. Use "focus left/right/up/down" instead.'
)
def split_last():
"""Goes to last split"""
# TODO: decide whether this notification is good style
actions.app.notify(
'"Split last" is not possible in windows terminal without special configuration. Use "focus left/right/up/down" instead.'
)
def split_number(index: int):
"""Navigates to a the specified split"""
actions.app.notify(
'"Split_number" is not possible in windows terminal in default configuration.'
)
def tab_final():
actions.key("ctrl-alt-9")