fd 0.5.0 → 0.6.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4fbb1328292e9e5ebe74262b8d9c91adf2d9d71e44055e81e1ecd1fb35965768
4
- data.tar.gz: 7dfc538b1293aa6b1690c74729c2a52fc0a8f5dc74bf4d04b75ebfa3aa18bceb
3
+ metadata.gz: 411fa810d518ecba93b02f527e32b125961260593583ad9aee2464e1d62d7d87
4
+ data.tar.gz: e0418c2115bebff4f09124c4331f7ec74f71932f8803220b87186e58fa6874c2
5
5
  SHA512:
6
- metadata.gz: 8dc642b1028e40559b8a868f01cf595eebd22b65678ad676abb4866865a5a43fedd46af54ede138b8bc82fdb269918580eb44779f10625ec0a86f4dde173a29b
7
- data.tar.gz: b18f4270ceb80cddccad59db720be725ce9f2e91ca43c7d2de580d9d2f469dd6d24282fcfd0ded09c91174405d9afd2df4db3fef6ee28b93dcb8972d77c79712
6
+ metadata.gz: 5128ae855d0e180f24a0f1c02febe0988190c3961fc71a6189c683c73dbb61c91f35e7d9a1b95a64e9125a76961e3790d24c0cb8472eaa2c5ea70d30fd3886fb
7
+ data.tar.gz: 174171890a8c4b1cf209c15b835442083c3820b2c29695036df91e91e1ceb37b8e8368e8509a1f95572da4d15470dd29cc7d320e4613ef3407046319db0e62ef
data/README.md CHANGED
@@ -42,37 +42,41 @@ You can pass _file names_ on the command line:
42
42
  fd [-w number] [file_names]
43
43
  ```
44
44
 
45
- For example:
45
+ For example (without colour highlighting of invisible characters):
46
46
 
47
47
  ```bash
48
48
  > echo "Bacon ipsum dolor amet short ribs flank irure filet mignon brisket buffalo est porchetta." > some_file
49
- > fd -w 7 some_file
49
+ > ~/dev/fd ᚠ main > fd -w 7 some_file
50
50
  some_file
51
- 42 61 63 6f 6e 20 69 | B a c o n __ i
52
- 70 73 75 6d 20 64 6f | p s u m __ d o
53
- 6c 6f 72 20 61 6d 65 | l o r __ a m e
54
- 74 20 73 68 6f 72 74 | t __ s h o r t
55
- 20 72 69 62 73 20 66 | __ r i b s __ f
56
- 6c 61 6e 6b 20 69 72 | l a n k __ i r
57
- 75 72 65 20 66 69 6c | u r e __ f i l
58
- 65 74 20 6d 69 67 6e | e t __ m i g n
59
- 6f 6e 20 62 72 69 73 | o n __ b r i s
60
- 6b 65 74 20 62 75 66 | k e t __ b u f
61
- 66 61 6c 6f 20 65 73 | f a l o __ e s
62
- 74 20 70 6f 72 63 68 | t __ p o r c h
63
- 65 74 74 61 2e 0a | e t t a . LF
51
+ 42 61 63 6f 6e 20 69 | B a c o ni
52
+ 70 73 75 6d 20 64 6f | p s u md o
53
+ 6c 6f 72 20 61 6d 65 | l o ra m e
54
+ 74 20 73 68 6f 72 74 | ts h o r t
55
+ 20 72 69 62 73 20 66 |r i b sf
56
+ 6c 61 6e 6b 20 69 72 | l a n ki r
57
+ 75 72 65 20 66 69 6c | u r ef i l
58
+ 65 74 20 6d 69 67 6e | e tm i g n
59
+ 6f 6e 20 62 72 69 73 | o nb r i s
60
+ 6b 65 74 20 62 75 66 | k e tb u f
61
+ 66 61 6c 6f 20 65 73 | f a l oe s
62
+ 74 20 70 6f 72 63 68 | tp o r c h
63
+ 65 74 74 61 2e 0a | e t t a .
64
64
  ```
65
65
 
66
- You can also pipe input to STDIN:
66
+ Here's a screenshot of a zsh session that shows the highlighting:
67
+
68
+ ![](images/usage_example.png)
69
+
70
+ You can also pipe input from STDIN:
67
71
 
68
72
  ```bash
69
73
  > echo "Put something into STDIN" | fd -w 5
70
74
  STDIN
71
- 50 75 74 20 73 | P u t __ s
72
- 6f 6d 65 74 68 | o m e t h
73
- 69 6e 67 20 69 | i n g __ i
74
- 6e 74 6f 20 53 | n t o __ S
75
- 54 44 49 4e 0a | T D I N LF
75
+ 50 75 74 20 73 | P u ts
76
+ 6f 6d 65 74 68 | o m e t h
77
+ 69 6e 67 20 69 | i n gi
78
+ 6e 74 6f 20 53 | n t oS
79
+ 54 44 49 4e 0a | T D I N
76
80
  ```
77
81
 
78
82
  ## Development
Binary file
data/lib/fd/version.rb CHANGED
@@ -4,7 +4,7 @@
4
4
  # All other code is in lib/fd.rb
5
5
  #
6
6
  class Fd
7
- VERSION = '0.5.0'
7
+ VERSION = '0.6.0'
8
8
 
9
9
  def self.version
10
10
  VERSION
data/lib/fd.rb CHANGED
@@ -7,6 +7,8 @@ require_relative 'fd/version'
7
7
  class Fd
8
8
  class Error < StandardError; end
9
9
 
10
+ ESCAPE_CHARACTERS = %w[␀ ␇ ␈ ␉ ␊ ␋ ␌ ␍ ␡ ␛ ␠]
11
+
10
12
  attr_reader :line_length, :char_table
11
13
 
12
14
  # _line_length_ sets how many characters are displayed per @line.
@@ -44,6 +46,10 @@ class Fd
44
46
  @char_table[32] = '␠'
45
47
  end
46
48
 
49
+ def add_esc_sequence(chr)
50
+ "\e[31m#{chr}\e[0m"
51
+ end
52
+
47
53
  # dumps the given file _file_name_ to stdout.
48
54
  def dump(content)
49
55
  raise "Not the expected encoding of UFT-8, got #{content.encoding}" unless content.encoding == Encoding::UTF_8
@@ -104,6 +110,8 @@ class Fd
104
110
  end
105
111
 
106
112
  def print_single_line
107
- puts("#{format("%#{(3 * line_length) - 1}s", hex_values.join(' '))} |#{format("%#{2 * line_length}s", line)}")
113
+ puts("#{format("%#{(3 * line_length) - 1}s", hex_values.join(' '))} |#{format("%#{2 * line_length}s", line)}".
114
+ gsub(/([#{ESCAPE_CHARACTERS.join('')}])/, add_esc_sequence('\1'))
115
+ )
108
116
  end
109
117
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephan Kämper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-13 00:00:00.000000000 Z
11
+ date: 2023-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard-bundler
@@ -173,6 +173,7 @@ files:
173
173
  - bin/fd
174
174
  - bin/setup
175
175
  - fd.gemspec
176
+ - images/usage_example.png
176
177
  - lib/fd.rb
177
178
  - lib/fd/version.rb
178
179
  homepage: https://github.com/s2k/fd