forked from talonhub/community
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unix_shell.py
56 lines (44 loc) · 1.47 KB
/
unix_shell.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
from talon import Context, Module, actions
ctx = Context()
mod = Module()
ctx.matches = r"""
tag: user.generic_unix_shell
"""
# Uncomment the following line to enable common unix utilities from unix_utilities.py
# ctx.tags = ["user.unix_utilities"]
@ctx.action_class("user")
class Actions:
# Implements the functions from terminal.py for unix shells
def terminal_list_directories():
"""Lists directories"""
actions.insert("ls")
actions.key("enter")
def terminal_list_all_directories():
"""Lists all directories including hidden"""
actions.insert("ls -a")
actions.key("enter")
def terminal_change_directory(path: str):
"""Lists change directory"""
actions.insert(f"cd {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.insert("clear")
actions.key("enter")
def terminal_run_last():
"""Repeats the last command"""
actions.key("up enter")
def terminal_rerun_search(command: str):
"""Searches through the previously executed commands"""
actions.key("ctrl-r")
actions.insert(command)
def terminal_kill_all():
"""kills the running command"""
actions.key("ctrl-c")
actions.insert("y")
actions.key("enter")