summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmjith Ramanujam <amjith.r@gmail.com>2022-03-30 16:54:06 -0700
committerGitHub <noreply@github.com>2022-03-30 16:54:06 -0700
commit3e9a977fbcb941e44526c05e64b16ea6a984c91b (patch)
tree8913ec402b7c956a76f76c5d5acf8f6ab6b562f1
parent191c1384b65e0fbd0b207a5ffff448d8b3421fb0 (diff)
parent8dbfd54bb70d364c65ca2c49d845ce61403f2e2c (diff)
Merge pull request #1044 from dbcli/RW/beep-after-long-query
Add configurable beep to notify the user after long queries
-rw-r--r--changelog.md4
-rwxr-xr-xmycli/main.py3
-rw-r--r--mycli/myclirc3
3 files changed, 10 insertions, 0 deletions
diff --git a/changelog.md b/changelog.md
index b5522d2..e47c8df 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,3 +1,7 @@
+Features:
+---------
+* Add `beep_after_seconds` option to `~/.myclirc`, to ring the terminal bell after long queries.
+
1.24.4 (2022/03/30)
===================
diff --git a/mycli/main.py b/mycli/main.py
index c13ed78..08f0755 100755
--- a/mycli/main.py
+++ b/mycli/main.py
@@ -138,6 +138,7 @@ class MyCli(object):
self.multi_line = c['main'].as_bool('multi_line')
self.key_bindings = c['main']['key_bindings']
special.set_timing_enabled(c['main'].as_bool('timing'))
+ self.beep_after_seconds = float(c['main']['beep_after_seconds'] or 0)
FavoriteQueries.instance = FavoriteQueries.from_config(self.config)
@@ -721,6 +722,8 @@ class MyCli(object):
self.output(formatted, status)
except KeyboardInterrupt:
pass
+ if self.beep_after_seconds > 0 and t >= self.beep_after_seconds:
+ self.echo('\a', err=True, nl=False)
if special.is_timing_enabled():
self.echo('Time: %0.03fs' % t)
except KeyboardInterrupt:
diff --git a/mycli/myclirc b/mycli/myclirc
index c89caa0..2418342 100644
--- a/mycli/myclirc
+++ b/mycli/myclirc
@@ -30,6 +30,9 @@ log_level = INFO
# Timing of sql statments and table rendering.
timing = True
+# Beep after long-running queries are completed; 0 to disable.
+beep_after_seconds = 0
+
# Table format. Possible values: ascii, double, github,
# psql, plain, simple, grid, fancy_grid, pipe, orgtbl, rst, mediawiki, html,
# latex, latex_booktabs, textile, moinmoin, jira, vertical, tsv, csv.