itt 0.1.3 → 0.1.5
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.
- checksums.yaml +13 -5
- data/bin/itt +7 -25
- data/lib/itt.rb +45 -0
- metadata +10 -7
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NjNmY2I2Y2RhYmUzNmJmNGYwNGFkNGNhNWI3NjcwYTExNDQ4YWZhZQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YzVlZmEyNWU2YThlMzllNWVkOWI1YzUyNGNhMjJhM2NjOWU0NzExOQ==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
Y2RjNGVlMmJmMmQ5ZWM4MzhjZmZiMGU3YTQzMzJlZmQ2MGY3YmNiNDg2ZDAy
|
10
|
+
YWVjM2YxZTM4Y2UyZjE2NjIxNzljNjU4MzJhYjY3NTUzOTFkMDJmNDhiMWFl
|
11
|
+
ZWM3YjcyNTg3OGFjZWJjMjY2YTFkODRhY2M1NThmYWU3YmM0YmI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NmZjZjNjMmVkNTMxYmNjZGFjMGQxZGY0MTg2OTE1YTc5ZDExMzQ2NmZhOTI2
|
14
|
+
NWE1MjFlYjU4NWEwNWQ0YjlkYzAwZGZhZmIzZmMwODNmNWU0MjI2NWE5N2Q1
|
15
|
+
ZThjYzAxNGI4NWE4YWYxM2ZkNWZkMmZlZjc0OWRiMjQ3M2Q3MjI=
|
data/bin/itt
CHANGED
@@ -1,31 +1,15 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
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
|
-
}
|
3
|
+
require 'itt'
|
4
|
+
|
5
|
+
include ITT
|
12
6
|
|
13
7
|
# Display help and exit if no arguments are given
|
14
8
|
if ARGV.count == 0
|
15
|
-
puts
|
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"
|
9
|
+
puts HELP
|
22
10
|
exit
|
23
11
|
end
|
24
12
|
|
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
13
|
# Clear the tab title and color
|
30
14
|
if ARGV[0] == 'clear'
|
31
15
|
print clear_color
|
@@ -33,14 +17,12 @@ if ARGV[0] == 'clear'
|
|
33
17
|
# If first argument matches one of the colors set the tab color ...
|
34
18
|
elsif rgb = COLORS.select { |k, _v| k.to_s =~ /^#{ARGV[0]}/ }.values[0]
|
35
19
|
red, green, blue = rgb
|
36
|
-
print
|
37
|
-
print "\e]6;1;bg;green;brightness;#{green}\a"
|
38
|
-
print "\e]6;1;bg;blue;brightness;#{blue}\a"
|
20
|
+
print set_color(red, green, blue)
|
39
21
|
# ... and if the second argument is present, set the title from the remaining
|
40
22
|
# arguments
|
41
|
-
print
|
23
|
+
print set_title ARGV[1..-1].join(' ') if ARGV[1]
|
42
24
|
# If first argument is not a clear command or color set the title from all
|
43
25
|
# arguments if at least one is present
|
44
26
|
elsif ARGV[0]
|
45
|
-
print
|
27
|
+
print set_title ARGV[0..-1].join(' ')
|
46
28
|
end
|
data/lib/itt.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
module ITT
|
2
|
+
VERSION = '0.1.5'
|
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
|
+
# Help info
|
14
|
+
HELP = ''
|
15
|
+
HELP << "Version: #{VERSION}\n\n"
|
16
|
+
HELP << "Sets the color and/or title of the current iTerm2 tab\n\n"
|
17
|
+
HELP << "USAGE:\nitt [color] title"
|
18
|
+
HELP << "\nExamples:\n\n\titt purple web-server\n\titt p web-server"
|
19
|
+
HELP << "\titt orange rails-console\n\n"
|
20
|
+
HELP << "Clear title and color:\n\n"
|
21
|
+
HELP << "\titt clear\n\n"
|
22
|
+
HELP << "Colors: #{COLORS.keys.map(&:to_s).join(', ')}\n\n"
|
23
|
+
|
24
|
+
# Escape sequence to set the title
|
25
|
+
def set_title(title)
|
26
|
+
"\e];#{title}\007"
|
27
|
+
end
|
28
|
+
|
29
|
+
# Escape sequences to set the color
|
30
|
+
def set_color(red, green, blue)
|
31
|
+
output = ''
|
32
|
+
output << "\e]6;1;bg;red;brightness;#{red}\a"
|
33
|
+
output << "\e]6;1;bg;green;brightness;#{green}\a"
|
34
|
+
output << "\e]6;1;bg;blue;brightness;#{blue}\a"
|
35
|
+
end
|
36
|
+
|
37
|
+
# Escape sequences to clear the title and color
|
38
|
+
def clear_color
|
39
|
+
"\e]6;1;bg;*;default\a"
|
40
|
+
end
|
41
|
+
|
42
|
+
def clear_title
|
43
|
+
"\e]1;\a"
|
44
|
+
end
|
45
|
+
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.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Ladachowski
|
@@ -18,35 +18,38 @@ extensions: []
|
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
20
|
- bin/itt
|
21
|
+
- lib/itt.rb
|
21
22
|
homepage: https://github.com/aladac/itt
|
22
23
|
licenses:
|
23
24
|
- MIT
|
24
25
|
metadata: {}
|
25
|
-
post_install_message:
|
26
|
-
|
26
|
+
post_install_message: ! 'If you are using zsh please add
|
27
|
+
|
27
28
|
|
28
29
|
export DISABLE_AUTO_TITLE=true
|
29
30
|
|
31
|
+
|
30
32
|
To .zshrc
|
31
33
|
|
34
|
+
|
35
|
+
'
|
32
36
|
rdoc_options: []
|
33
37
|
require_paths:
|
34
38
|
- lib
|
35
39
|
required_ruby_version: !ruby/object:Gem::Requirement
|
36
40
|
requirements:
|
37
|
-
- -
|
41
|
+
- - ! '>='
|
38
42
|
- !ruby/object:Gem::Version
|
39
43
|
version: 1.9.3
|
40
44
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
45
|
requirements:
|
42
|
-
- -
|
46
|
+
- - ! '>='
|
43
47
|
- !ruby/object:Gem::Version
|
44
48
|
version: '0'
|
45
49
|
requirements: []
|
46
50
|
rubyforge_project:
|
47
|
-
rubygems_version: 2.4.
|
51
|
+
rubygems_version: 2.4.5
|
48
52
|
signing_key:
|
49
53
|
specification_version: 4
|
50
54
|
summary: itt
|
51
55
|
test_files: []
|
52
|
-
has_rdoc:
|