fd 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -21
- data/images/usage_example.png +0 -0
- data/lib/fd/version.rb +1 -1
- data/lib/fd.rb +9 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 411fa810d518ecba93b02f527e32b125961260593583ad9aee2464e1d62d7d87
|
4
|
+
data.tar.gz: e0418c2115bebff4f09124c4331f7ec74f71932f8803220b87186e58fa6874c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 |
|
52
|
-
70 73 75 6d 20 64 6f |
|
53
|
-
6c 6f 72 20 61 6d 65 |
|
54
|
-
74 20 73 68 6f 72 74 |
|
55
|
-
20 72 69 62 73 20 66 |
|
56
|
-
6c 61 6e 6b 20 69 72 |
|
57
|
-
75 72 65 20 66 69 6c |
|
58
|
-
65 74 20 6d 69 67 6e |
|
59
|
-
6f 6e 20 62 72 69 73 |
|
60
|
-
6b 65 74 20 62 75 66 |
|
61
|
-
66 61 6c 6f 20 65 73 |
|
62
|
-
74 20 70 6f 72 63 68 |
|
63
|
-
65 74 74 61 2e 0a |
|
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 . ␊
|
64
64
|
```
|
65
65
|
|
66
|
-
|
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 |
|
72
|
-
6f 6d 65 74 68 |
|
73
|
-
69 6e 67 20 69 |
|
74
|
-
6e 74 6f 20 53 |
|
75
|
-
54 44 49 4e 0a |
|
75
|
+
50 75 74 20 73 | P u t ␠ s
|
76
|
+
6f 6d 65 74 68 | o m e t h
|
77
|
+
69 6e 67 20 69 | i n g ␠ i
|
78
|
+
6e 74 6f 20 53 | n t o ␠ S
|
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
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.
|
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-
|
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
|