From d0ed535663aa6b05d06b4f386c1e65422b7bbaa1 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 7 Jan 2022 05:35:43 +0000 Subject: dtas-console: set X11 terminal title iff DISPLAY is set This allows users running terminals in graphical environments to navigate to the terminal running dtas-console more easily. --- bin/dtas-console | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 +# Copyright (C) all contributors # License: GPL-3.0+ # 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) -- cgit v1.2.3-24-ge0c7