-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmsys2.py
More file actions
119 lines (95 loc) · 2.97 KB
/
msys2.py
File metadata and controls
119 lines (95 loc) · 2.97 KB
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
from talon import Context, Module, actions, imgui, settings, ui
import os
import subprocess
mod = Module()
mod.apps.mintty = """
os: windows
and app.name: Terminal
os: windows
and app.name: mintty.exe
os: windows
and app.name: MSYS2 terminal
os: windows
and app.exe: mintty.exe
"""
ctx = Context()
ctx.matches = r"""
app: mintty
"""
directories_to_remap = {}
directories_to_exclude = {}
setting_cyg_path = mod.setting(
"cygpath",
type=str,
default="C:\\cygwin64\\bin\\cygpath.exe",
desc="Path to cygpath.exe",
)
def get_win_path(cyg_path):
path = ""
try:
path = (
subprocess.check_output([setting_cyg_path.get(), "-w", cyg_path])
.strip(b"\n")
.decode()
)
except:
path = ""
return path
@ctx.action_class("user")
class user_actions:
def file_manager_current_path():
path = ui.active_window().title
path = get_win_path(path)
if path in directories_to_remap:
path = directories_to_remap[title]
if path in directories_to_exclude:
path = ""
return path
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 = '"{}"'.format(path)
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"""
name = '"{}"'.format(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_open_volume(volume: str):
"""file_manager_open_volume"""
actions.user.file_manager_open_directory(volume)
def terminal_list_directories():
actions.insert("ls")
actions.key("enter")
def terminal_list_all_directories():
actions.insert("ls -a")
actions.key("enter")
def terminal_change_directory(path: str):
actions.insert("cd {}".format(path))
if path:
actions.key("enter")
def terminal_change_directory_root():
"""Root of current drive"""
actions.insert("cd /")
actions.key("enter")
def terminal_clear_screen():
"""Clear screen"""
actions.key("ctrl-l")
def terminal_run_last():
actions.key("up enter")
def terminal_kill_all():
actions.key("ctrl-c")
actions.insert("y")
actions.key("enter")