about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2022-01-07 05:35:43 +0000
committerEric Wong <e@80x24.org>2022-01-11 18:22:07 +0000
commitd0ed535663aa6b05d06b4f386c1e65422b7bbaa1 (patch)
tree3794c3b1b35a758c30d148e7fe7663138f338ebb
parent593b3a2bd374c30ee9e62cfa7144bb371d82f10e (diff)
downloaddtas-d0ed535663aa6b05d06b4f386c1e65422b7bbaa1.tar.gz
This allows users running terminals in graphical environments to
navigate to the terminal running dtas-console more easily.
-rwxr-xr-xbin/dtas-console7
1 files changed, 6 insertions, 1 deletions
diff --git a/bin/dtas-console b/bin/dtas-console
index 0c56450..6172863 100755
--- a/bin/dtas-console
+++ b/bin/dtas-console
@@ -1,5 +1,5 @@
 #!/usr/bin/env ruby
-# Copyright (C) 2013-2021 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 #
@@ -26,6 +26,7 @@ w.req_ok('watch')
 c = DTAS::UNIXClient.new
 cur = YAML.load(c.req('current'))
 readable = [ se, w, $stdin ]
+set_title = ENV['DISPLAY'] ? $stdout : nil
 
 # current rg mode
 rg_mode = DTAS::RGState::RG_MODE.keys.unshift("off")
@@ -167,6 +168,10 @@ begin
       # and risk mojibake...
       infile.encode(enc_locale,
                     undef: :replace, invalid: :replace, replace: '?')
+      if set_title
+        dir, base = File.split(infile)
+        set_title.syswrite("\033]0;#{base} dtas-console\07")
+      end
       Curses.setpos(lineno += 1, 0)
       Curses.clrtoeol
       Curses.addstr(infile)