itt 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/bin/itt +44 -0
  3. metadata +46 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 148149d7616bdd7fa142548d0af1cbc6637e371f
4
+ data.tar.gz: 6bc925e4f6241045449987fe322e59b411dc150e
5
+ SHA512:
6
+ metadata.gz: ce994f2a2c284df3cef56cb923ae5c5ef23cfe837ee16da36f7fa926b784219a20ac56b2fe151bc0b7e485f7498098eb8265b118a761481f22dcf63c6af740de
7
+ data.tar.gz: a9ec8162a41352405bc80b9c11666a08efd3090c151d2ac68b802b2e27414f7797329cdad6dd7de7a6817a608c5f547ceb2bb5a3498848e5750708a93aeb4297
data/bin/itt ADDED
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Predefined colors, as close to the default iTerm2 tab colors as possible
4
+ COLORS = {
5
+ red: [214, 110, 107],
6
+ green: [183, 213, 103],
7
+ blue: [117, 165, 236],
8
+ orange: [223, 157, 78],
9
+ yellow: [167, 160, 96],
10
+ purple: [140, 121, 149]
11
+ }
12
+
13
+ # Display help and exit if no arguments are given
14
+ if ARGV.count == 0
15
+ puts "Sets the color and/or title of the current iTerm2 tab\n\n"
16
+ puts "USAGE:\nitt [color] title"
17
+ puts "\nExamples:\n\n\titt purple web-server\n\titt p web-server"
18
+ puts "\titt orange rails-console\n\n"
19
+ puts "Colors: #{COLORS.keys.map(&:to_s).join(', ')}\n\n"
20
+ exit
21
+ end
22
+
23
+ # Escape sequenes to clear the title and color
24
+ clear_color = "\e]6;1;bg;*;default\a"
25
+ clear_title = "\e]1;\a"
26
+
27
+ # Clear the tab title and color
28
+ if ARGV[0] == 'clear'
29
+ print clear_color
30
+ print clear_title
31
+ # If first argument matches one of the colors set the tab color ...
32
+ elsif rgb = COLORS.select { |k, _v| k.to_s =~ /^#{ARGV[0]}/ }.values[0]
33
+ red, green, blue = rgb
34
+ print "\e]6;1;bg;red;brightness;#{red}\a"
35
+ print "\e]6;1;bg;green;brightness;#{green}\a"
36
+ print "\e]6;1;bg;blue;brightness;#{blue}\a"
37
+ # ... and if the second argument is present, set the title from the remaining
38
+ # arguments
39
+ print "\e];#{ARGV[1..-1].join(' ')}\007" if ARGV[1]
40
+ # If first argument is not a clear command or color set the title from all
41
+ # arguments if at least one is present
42
+ elsif ARGV[0]
43
+ print "\e]; #{ARGV[0..-1].join(' ')}\007"
44
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: itt
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Adam Ladachowski
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-05 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: iTerm2 tabs color and title util
14
+ email: adam@saiden.pl
15
+ executables:
16
+ - itt
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - bin/itt
21
+ homepage: https://github.com/aladac/itt
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.4.6
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: itt
45
+ test_files: []
46
+ has_rdoc: