mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 00:35:00 +00:00
feat: Add notifications-command option to run custom notification commands
This commit is contained in:
parent
f661025acc
commit
65e059a7d2
3 changed files with 18 additions and 1 deletions
|
@ -819,6 +819,12 @@ def get_parser(default_config_files, git_root):
|
|||
default=False,
|
||||
help="Enable/disable terminal bell notifications when LLM responses are ready (default: False)",
|
||||
)
|
||||
group.add_argument(
|
||||
"--notifications-command",
|
||||
metavar="COMMAND",
|
||||
default=None,
|
||||
help="Specify a command to run for notifications instead of the terminal bell",
|
||||
)
|
||||
group.add_argument(
|
||||
"--detect-urls",
|
||||
action=argparse.BooleanOptionalAction,
|
||||
|
|
12
aider/io.py
12
aider/io.py
|
@ -208,6 +208,7 @@ class InputOutput:
|
|||
num_user_asks = 0
|
||||
clipboard_watcher = None
|
||||
bell_on_next_input = False
|
||||
notifications_command = None
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
@ -237,6 +238,7 @@ class InputOutput:
|
|||
multiline_mode=False,
|
||||
root=".",
|
||||
notifications=False,
|
||||
notifications_command=None,
|
||||
):
|
||||
self.placeholder = None
|
||||
self.interrupted = False
|
||||
|
@ -245,6 +247,7 @@ class InputOutput:
|
|||
self.multiline_mode = multiline_mode
|
||||
self.bell_on_next_input = False
|
||||
self.notifications = notifications
|
||||
self.notifications_command = notifications_command
|
||||
no_color = os.environ.get("NO_COLOR")
|
||||
if no_color is not None and no_color != "":
|
||||
pretty = False
|
||||
|
@ -954,7 +957,14 @@ class InputOutput:
|
|||
def ring_bell(self):
|
||||
"""Ring the terminal bell if needed and clear the flag"""
|
||||
if self.bell_on_next_input and self.notifications:
|
||||
print("\a", end="", flush=True) # Ring the bell
|
||||
if self.notifications_command:
|
||||
try:
|
||||
import subprocess
|
||||
subprocess.run(self.notifications_command, shell=True)
|
||||
except Exception as e:
|
||||
self.tool_warning(f"Failed to run notifications command: {e}")
|
||||
else:
|
||||
print("\a", end="", flush=True) # Ring the bell
|
||||
self.bell_on_next_input = False # Clear the flag
|
||||
|
||||
def toggle_multiline_mode(self):
|
||||
|
|
|
@ -560,6 +560,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
|||
fancy_input=args.fancy_input,
|
||||
multiline_mode=args.multiline,
|
||||
notifications=args.notifications,
|
||||
notifications_command=args.notifications_command,
|
||||
)
|
||||
|
||||
io = get_io(args.pretty)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue