itt 0.1.3 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. checksums.yaml +5 -5
  2. data/bin/itt +6 -25
  3. data/lib/itt.rb +48 -0
  4. data/lib/version.rb +3 -0
  5. metadata +19 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c0df3fff4950121fcf1523b5f4705159600673e3
4
- data.tar.gz: 8b8f382905a5965c1e3c75fb66db273d220a7cc8
2
+ SHA256:
3
+ metadata.gz: a8a0e8d4c59d267db4da28b9757ad12fa640fd6c0de4fe0ce7395526b1d3e2f8
4
+ data.tar.gz: ab0e0225f2558ec0d131a88364aeadb645213296337cdbd50198ae2408fe44fb
5
5
  SHA512:
6
- metadata.gz: 4e495b80cbc9047d5d6c838c0e943eb915a8ae8821e00d14a859bfcb02b5b14dfdfac04a8d20a53a474ce62151a101206ea14a3d8bc43f00f477622386a6d722
7
- data.tar.gz: beaddb05081f36c0309051a70ff68096efe260b0d7541a9479f8b8979cfe157473e0d6ad6d89aac904b2d42b7661611659869a53f54e7631e801ca57133206be
6
+ metadata.gz: 312f7b36d69e1b3e5822220cc4fff67fef807edae4258ef022542ab8c4530162228a49419be4c434ffda3efe07fa06972d613113e364c92cef07d72c95e491a7
7
+ data.tar.gz: 7785db00bde3f3541d35f7f2bc76e0aaab1f49c5146c4a305cea6b3153bb98ddb553204e2b5f101c693fcfb201bc7c1103d8ddecacd239907599ef3157f88711
data/bin/itt CHANGED
@@ -1,31 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
+ require 'itt'
2
3
 
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
- }
4
+ include ITT
12
5
 
13
6
  # Display help and exit if no arguments are given
14
7
  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 "Clear title and color:\n\n"
20
- puts "\titt clear\n\n"
21
- puts "Colors: #{COLORS.keys.map(&:to_s).join(', ')}\n\n"
8
+ puts HELP
22
9
  exit
23
10
  end
24
11
 
25
- # Escape sequenes to clear the title and color
26
- clear_color = "\e]6;1;bg;*;default\a"
27
- clear_title = "\e]1;\a"
28
-
29
12
  # Clear the tab title and color
30
13
  if ARGV[0] == 'clear'
31
14
  print clear_color
@@ -33,14 +16,12 @@ if ARGV[0] == 'clear'
33
16
  # If first argument matches one of the colors set the tab color ...
34
17
  elsif rgb = COLORS.select { |k, _v| k.to_s =~ /^#{ARGV[0]}/ }.values[0]
35
18
  red, green, blue = rgb
36
- print "\e]6;1;bg;red;brightness;#{red}\a"
37
- print "\e]6;1;bg;green;brightness;#{green}\a"
38
- print "\e]6;1;bg;blue;brightness;#{blue}\a"
19
+ print set_color(red, green, blue)
39
20
  # ... and if the second argument is present, set the title from the remaining
40
21
  # arguments
41
- print "\e];#{ARGV[1..-1].join(' ')}\007" if ARGV[1]
22
+ print set_title ARGV[1..-1].join(' ') if ARGV[1]
42
23
  # If first argument is not a clear command or color set the title from all
43
24
  # arguments if at least one is present
44
25
  elsif ARGV[0]
45
- print "\e]; #{ARGV[0..-1].join(' ')}\007"
26
+ print set_title ARGV[0..-1].join(' ')
46
27
  end
data/lib/itt.rb ADDED
@@ -0,0 +1,48 @@
1
+ require 'version'
2
+ require 'rumoji'
3
+ module ITT
4
+ # Predefined colors, as close to the default iTerm2 tab colors as possible
5
+ COLORS = {
6
+ red: [214, 110, 107],
7
+ green: [183, 213, 103],
8
+ blue: [117, 165, 236],
9
+ orange: [223, 157, 78],
10
+ yellow: [167, 160, 96],
11
+ purple: [140, 121, 149]
12
+ }
13
+
14
+ # Help info
15
+ HELP = ''
16
+ HELP << "Version: #{VERSION}\n\n"
17
+ HELP << "Sets the color and/or title of the current iTerm2 tab\n\n"
18
+ HELP << "USAGE:\nitt [color] title"
19
+ HELP << "\nExamples:\n\n\titt purple web-server\n\titt p web-server"
20
+ HELP << "\titt orange rails-console\n"
21
+ HELP << "\titt blue :whale: docker\n\n"
22
+ HELP << "Clear title and color:\n\n"
23
+ HELP << "\titt clear\n\n"
24
+ HELP << "Colors: #{COLORS.keys.map(&:to_s).join(', ')}\n\n"
25
+ HELP << "Emoji cheat-sheet: http://www.emoji-cheat-sheet.com\n\n"
26
+
27
+ # Escape sequence to set the title
28
+ def set_title(title)
29
+ "\e];#{Rumoji.decode(title)}\007"
30
+ end
31
+
32
+ # Escape sequences to set the color
33
+ def set_color(red, green, blue)
34
+ output = ''
35
+ output << "\e]6;1;bg;red;brightness;#{red}\a"
36
+ output << "\e]6;1;bg;green;brightness;#{green}\a"
37
+ output << "\e]6;1;bg;blue;brightness;#{blue}\a"
38
+ end
39
+
40
+ # Escape sequences to clear the title and color
41
+ def clear_color
42
+ "\e]6;1;bg;*;default\a"
43
+ end
44
+
45
+ def clear_title
46
+ "\e]1;\a"
47
+ end
48
+ end
data/lib/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module ITT
2
+ VERSION = '0.1.7'
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Ladachowski
@@ -9,7 +9,21 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2015-09-06 00:00:00.000000000 Z
12
- dependencies: []
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rumoji
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.4'
13
27
  description: iTerm2 tabs color and title util
14
28
  email: adam@saiden.pl
15
29
  executables:
@@ -18,6 +32,8 @@ extensions: []
18
32
  extra_rdoc_files: []
19
33
  files:
20
34
  - bin/itt
35
+ - lib/itt.rb
36
+ - lib/version.rb
21
37
  homepage: https://github.com/aladac/itt
22
38
  licenses:
23
39
  - MIT
@@ -43,10 +59,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
43
59
  - !ruby/object:Gem::Version
44
60
  version: '0'
45
61
  requirements: []
46
- rubyforge_project:
47
- rubygems_version: 2.4.6
62
+ rubygems_version: 3.0.3.1
48
63
  signing_key:
49
64
  specification_version: 4
50
65
  summary: itt
51
66
  test_files: []
52
- has_rdoc: