Sha256: fd5dd44dab24c0f8720212f939ac5efb76b80f207d2a13aae30502ec9d7ab56a

Contents?: true

Size: 839 Bytes

Versions: 16

Compression:

Stored size: 839 Bytes

Contents

require "guard/notifiers/base"

module Guard
  module Notifier
    # Shows system notifications in the terminal title bar.
    #
    class TerminalTitle < Base
      # Shows a system notification.
      #
      # @param [Hash] opts additional notification library options
      # @option opts [String] message the notification message body
      # @option opts [String] type the notification type. Either 'success',
      #   'pending', 'failed' or 'notify'
      # @option opts [String] title the notification title
      #
      def notify(message, opts = {})
        super

        first_line = message.sub(/^\n/, "").sub(/\n.*/m, "")

        STDOUT.puts "\e]2;[#{ opts[:title] }] #{ first_line }\a"
      end

      # Clears the terminal title
      #
      def self.turn_off
        STDOUT.puts "\e]2;\a"
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
guard-2.10.5 lib/guard/notifiers/terminal_title.rb
guard-2.10.4 lib/guard/notifiers/terminal_title.rb
guard-2.10.3 lib/guard/notifiers/terminal_title.rb
guard-2.10.2 lib/guard/notifiers/terminal_title.rb
guard-2.10.1 lib/guard/notifiers/terminal_title.rb
guard-2.10.0 lib/guard/notifiers/terminal_title.rb
guard-2.9.2 lib/guard/notifiers/terminal_title.rb
guard-2.9.1 lib/guard/notifiers/terminal_title.rb
guard-2.9.0 lib/guard/notifiers/terminal_title.rb
guard-2.8.2 lib/guard/notifiers/terminal_title.rb
guard-2.8.1 lib/guard/notifiers/terminal_title.rb
guard-2.8.0 lib/guard/notifiers/terminal_title.rb
guard-2.7.3 lib/guard/notifiers/terminal_title.rb
guard-2.7.2 lib/guard/notifiers/terminal_title.rb
guard-2.7.1 lib/guard/notifiers/terminal_title.rb
guard-2.7.0 lib/guard/notifiers/terminal_title.rb