Skip to content

Latest commit

 

History

History
1291 lines (1099 loc) · 51.9 KB

DOCUMENTATION.md

File metadata and controls

1291 lines (1099 loc) · 51.9 KB

cat_win

Simple Command-line Tool made in Python
Explore the code »

Report Bug · Request Feature

Table of Contents
  1. Arguments & Options

> catw [FILE]... [OPTION]...
> catw --help
> cats [OPTION]...
> cats --help
Argument / Option Description works in REPL
-h, --help show help message and exit
-v, --version output version information and exit
--debug, --debug show debug information
-l, --linelength display the length of each line
-n, --number number all output lines
--fp, --file-prefix include the file in every line prefix
-e, --ends display $ at the end of each line
--chr, --char display special characters
-b, --blank hide empty lines
-p, --peek only print the first and last lines
-r, --reverse reverse output
-u, --unique suppress repeated output lines
--sort, --sort sort all lines alphabetically
--sortl, --sortlength sort all lines by length
--sf, --specific-format automatically format specific file types
-E, --echo handle every following parameter as stdin
-, --stdin use stdin
-o, --oneline take only the first stdin-line
-U, --url display the contents of any provided url
-f, --files list applied files and file sizes
-d, --dirs list found directories
-s, --sum show sum of lines
-w, --wordcount display the wordcount
--cc, --charcount display the charcount
-g, --grep only show lines containing queried keywords or patterns
--nk, --nokeyword inverse the grep output
--nb, --nobreak do not interrupt the output
-a, --attributes show meta-information about the files
-m, --checksum show the checksums of all files
--strings, --strings print the sequences of printable characters
--b64d, --b64d decode the input from base64
--b64e, --b64e encode the input to base64
--eval, --EVAL evaluate simple mathematical equations
--hex, --HEX convert hexadecimal numbers to binary, octal and decimal
--dec, --DEC convert decimal numbers to binary, octal and hexadecimal
--oct, --oct convert octal numbers to binary, decimal and hexadecimal
--bin, --BIN convert binary numbers to octal, decimal and hexadecimal
--binview, --binview display the raw byte representation in binary
--hexview, --HEXVIEW display the raw byte representation in hexadecimal
-!, --edit open each file in a simple editor
-#, --hexedit open each file in a simple hex-editor
-M, --more page through the file step by step
-B, --raw open the file as raw bytes
-c, --clip copy output to clipboard
--dot, --dotfiles additionally query and edit dotfiles
--plain, --plain-only ignore non-plaintext files automatically
--nc, --nocolor disable colored output
--config, --config change default parameters
--cconfig, --cconfig change color configuration
--config-clear, --config-reset reset the config to default settings
--cconfig-clear, --cconfig-reset reset the color config to default settings
--config-remove, --cconfig-remove remove the config-file
-R, --R<stream> reconfigure the std-stream(s) with the parsed encoding
<stream> = 'in'/'out'/'err' (default is stdin & stdout)
enc=X, enc꞉X set file enconding to X (default is utf-8)
find=X, find꞉X find/query a substring X in the given files
match=X, match꞉X find/query a pattern X in the given files
trunc=X꞉Y, trunc꞉X꞉Y truncate file to lines X and Y (python-like)
[a,b] replace a with b in every line
[a꞉b꞉c] python-like string indexing syntax (line by line)

General Information

  • Order of Operation
    • Files will be used in the same Order as they were provided.
    • When passing in a File-pattern or a Directory the Files will be used in the Order in which they were found. This will often be alphabetically, although this is not guaranteed.
    • URLs will be used in the Order as they were provided, after all Files have been displayed.
    • Arguments will for the most part be used in the same Order as they were provided, yet there are some Exceptions.
  • Case-Sensitivity
    • The Arguments are case-sensitive.
    • Some Arguments have slightly different Behaviour when using upper- or lowercase Letters.
  • Chaining
    • One-letter Arguments can be chained together (e.g. -l -n -c is equivalent to -lnc)
  • Input Order
    • No specific Order for passing in Arguments or Files is neccessary.
    • Arguments, Files and Urls may be passed in without any Rules to ordering (e.g. catw file1 -argument url -argument2 file2).
    • If the same Argument is passed in multiple times only the first occurence is being counted.
  • Unknown Files
    • When encountering unknown Files the User is being prompted to write to Stdin.
    • The Stdin is being used to then write the Files.
    • When using the --stdin Parameter unknown Files will be automatically written with the content of StdIn.
  • Coloring
    • The Output will contain Color by Default.
    • cat_win will not explicitly add Color if the Argument --nc, --nocolor is used. (The Output may still contain Color if a File itself contains the ANSI-Color-Coding.)
    • The Output will be stripped of any Color if the Output is piped and the Configuration strip_color_on_pipe is set to true .

Displays the help Message. This Message is for the most part equivalent to the Table above. The Code execution will stop after showing this Message. This Argument has Priority over all other Arguments, hence the Order of passing this Argument in makes no Difference. If no Arguments or Files are provided, the help Parameter will be used by Default.

Displays a short Message containing basic Information about the Code. This includes the version Number but also the installation Directory. The Code execution will stop after showing this Message.

> catw -v

------------------------------------------------------------------------------
Catw <Version> - from <Path>
------------------------------------------------------------------------------

Built with:     Python <PyVersion>
Install time:   YYYY-MM-DD HH:MM:SS
Author:         Silas A. Kraume

Displays debug Information before and after the Code execution. This Argument is not shown in the default help Message and is provided for Developers/Development.


Displays the Length of each Line as a Prefix to the Line itself. This Argument will be used at the end such that other Arguments may influence the Length of the Lines beforehand.

> catw test.txt -l
[ 6] line 1
[10] long_line!

Numbers all Lines. The Numberisation is done at the Beginning such that different Arguments may disorganize the Numberisation again. Each File starts with line Number 1 therefor multiple Files are not consecutively numbered. If multiple Files are provided, the Prefix will also include the Number of the File.

> catw test.txt -n
1) line 1
2) line 2
> catw test.txt test.txt -n
1.1) line 1
1.2) line 2
2.1) line 1
2.2) line 2

Shows the Path to the File in each Line prefix. This can be useful when querying for Substrings or Patterns such that only a few Lines are being displayed. Using this Argument in uppercase (--FP, --FILEPREFIX) will result in the Path being shown as the url file Protocol. This can be useful in case the Terminal supports interacting with Links such that the File can be instantly opened. Using the lowercase Argument in Combination with the -n, --number Parameter a GNU-style link format will be displayed.

> catw test.txt --fp
<Path>/test.txt line 1
<Path>/test.txt line 2
> catw test.txt --FP -n
1) file:///<Path>/test.txt line 1
2) file:///<Path>/test.txt line 2
> catw test.txt --fp -n
<Path>/test.txt:1 line 1
<Path>/test.txt:2 line 2

Displays a '$' Character at the End of each Line. This can be useful to detect Whitespaces.

> catw test.txt --ends
Tab:    $
line 2$

Replaces every special Character with a readable Token. Each Token starts with the '^' Character, followed by a short ASCII Descriptor. Note that the special Char ␛ will not be displayed as ^ESC because it is needed for the colored output.

> catw test.txt
�����    �
> catw test.txt --chr
^SUB^SUB^NUL^SUB^SUB^TAB^BEL

Removes empty Lines from the Output. Beware that other Arguments can change a Line to be not empty beforehand.

> catw test.txt -nb
1) Empy Line follows:
3) Empty Line just got skipped!

Only displays the first and last 5 Lines of each File. Between the Beginning and End of the File will be displayed how many Lines have been skipped. Useful for getting a quick impression of how data in a given File is structured. This Argument is ignored when provided alongside with Queries for Substrings of Patterns or the -M, --more Parameter. Does nothing when the File has at most 10 Lines.

> catw test.txt -p
Line 1
Line 2
Line 3
Line 4
Line 5
  :
  10
  :
Line 16
Line 17
Line 18
Line 19
Line 20

Simply reverses the Content of all Files as well as the Ordering of all Files themselves.

> catw test1.txt test2.txt -p
Line 2 From Test2
Line 1 From Test2
Line 2 From Test1
Line 1 From Test1

Suppresses repeated Lines if they occur exactly one after the other.

> catw test.txt
This is a line!
This is a line!
This is a line!
This is also a line!
This is a line!
> catw test.txt --unique
This is a line!
This is also a line!
This is a line!

Sorts the Output alphabetically without case sensitivity.

> catw test.txt --sort -n
2) A line that has been sorted to the top!
1) This line was originally at the top!

Sorts the Output by Line Length.

> catw test.txt --sortl -l
[13] A short line!
[21] This line was on top!

Automatically format specific File Types. Currently supported are .json and .xml.

> catw --sf -E '{"person":{"name":"Alice","age":25,"employees":[{"name":"Bob"},{"name:":"David"}]}}'
{
  "person": {
    "name": "Alice",
    "age": 25,
    "employees": [
      {
        "name": "Bob"
      },
      {
        "name:": "David"
      }
    ]
  }
}
> catw --sf -E '<lib><book id="1"><title>Cats</title></book><book id="2"></book></lib>'
<?xml version="1.0" ?>
<lib>
  <book id="1">
    <title>Cats</title>
  </book>
  <book id="2"/>
</lib>

Everything passed in after this Argument will be handled as its own File. It is not possible to break out of this state therefor this Parameter must be used last. The Input is unicode-escaped (\n will be interpreted as an actual Newline) if the Config Option unicode_escaped_echo is set but in Case of an unicode-error the Input will simply be used literally. This way it is possible to define new lines (\n) or other special characters.

> catw -l --echo -n The last 'Parameter' does not count!\nThis is not a newline!
[57] -n The last Parameter does not count!\nThis is not a newline!
> catw -l -E -n The last 'Parameter' does not count!\nThis is a newline!
[37] -n The last Parameter does not count!
[18] This is a newline!

Using this Argument allows to pass in Data via the Stdin Stream. The Stdin Pipe will be handled as its own File.

> echo Hello World! | catw - -n
1) Hello World!

Limits the Stdin Stream to the first Line. Can only be used in Combination with -, --stdin.

> catw test.txt
Line 1
Line 2
Line 3
> catw test.txt | catw - -o
Line 1

When using this Parameter it is possible to provide URLs as Arguments. Should an URL not have a scheme (http(s):// or fttp(s):// ...) the default scheme (https://) is being used. Provided URLs are simply curl'd and handled as its own File. When not providing a raw Data URL the Content will include the HTML Elements.

> catw -U https://github.com/SilenZcience/cat_win > cat.html

Displays a small Summary at the End of Code execution showing every File used and their file Size. Using this Argument in uppercase (-F, --FILES) will ONLY display the Summary and stop Code execution.

> catw test.txt -f
Line 1
Line 2

applied FILE(s):
        13.0 B   <Path>/test.txt
Sum:    13.0 B
Amount: 1
> catw test.txt --FILES
applied FILE(s):
        13.0 B   <Path>/test.txt
Sum:    13.0 B
Amount: 1

Displays a small Summary at the End of Code execution showing every Directory found. Using this Argument in uppercase (-D, --DIRS) will ONLY display the Summary and stop Code execution.

> catw ./** -d
Line 1
Line 2
...

found DIR(s):
        <Path>
        <Path>/<PathA>
        <Path>/<PathA>/<PathAA>
        <Path>/<PathB>
Amount: 4
> catw ./** -D
found DIR(s):
        <Path>
        <Path>/<PathA>
        <Path>/<PathA>/<PathAA>
        <Path>/<PathB>
Amount: 4

Displays a small Message at the End of Code execution showing the Number of the Amount of all Lines received. Using this Argument in uppercase (-S, --SUM) will ONLY show this Message as well as a small Summary. This Summary will show the line Sum for each File. Duplicate Files will not be displayed multiple times within the Summary. The uppercase version of this Parameter will stop Code execution.

> catw test.txt --sum
Line 1
Line 2

Lines (Sum): 2
> catw test.txt test.txt --SUM
File             LineCount
<Path>/test.txt  2

Lines (Sum): 4

Displays a Summary of all Tokens/Words found in the given Files and how frequent they occured. The Output will be sorted by the Frequency of Occurrence starting with the most common Word. In Addition the used Files will be displayed beforehand. Using this Argument in uppercase (-W, --WORDCOUNT) will ONLY display this Message and stop Code execution.

> catw test.txt
it is true for all that, that that 'that' which that 'that' refers to is not the same 'that' which that 'that' refers to
> catw test.txt -W
The word count includes the following files:
    <Path>

that: 9
': 8
is: 2
refers: 2
to: 2
which: 2
,: 1
all: 1
for: 1
it: 1
not: 1
same: 1
the: 1
true: 1

Displays a Summary of all Chars/Letters found in the given Files and how frequent they occured. Whitespace Chars like Spaces and Tabs will be wrapped with quotes. The Output will be sorted by the Frequency of Occurrence starting with the most common Char. In Addition the used Files will be displayed beforehand. Using this Argument in uppercase (--CC, --CHARCOUNT) will ONLY display this Message and stop Code execution.

> catw test.txt
it is true for all that, that that 'that' which that 'that' refers to is not the same 'that' which that 'that' refers to
> catw test.txt --CC
The char count includes the following files:
    <Path>

t: 24
' ': 23
h: 14
a: 11
': 8
e: 7
r: 6
i: 5
s: 5
o: 4
f: 3
c: 2
l: 2
w: 2
,: 1
m: 1
n: 1
u: 1

Skips every Line that does not contain any matched Patterns or queried Substrings. Literals or Patterns to look for can be set using the find=X, find꞉X and match=X, match꞉X Keywords. Using this Argument in uppercase (-G, --GREP) will ONLY display the parts of each Line that matched any Pattern or Literal. Should multiple Queries be found in the same Line they will be seperated by comma. The uppercase Variant of this Parameter has priority (over the lowercase Variant as well as --nk, --nokeyword).

> catw test.txt find=cat -gn
1) cat_win!
4) one cat!& two cat!& three cat
> catw test.txt match=.cat. -Gn
4)  cat!, cat!

Inverse to the -g, --grep Argument. Skips every Line that does contain any matched Patterns or queried Substrings. The Combination of --nokeyword and -g, --grep means that no Output will be displayed.

> catw test.txt find=cat -n --nk
2) This Line is boring
3) This Line also does not contain 'c a t'
5) This Line neither

Using this Argument will open non-plaintext Files automatically without prompting the User. In Addition the Output will not stop on queried Substrings or Patterns. This Behaviour is included by Default when using --nk, --nokeyword or -g, --grep.


Shows meta Information for each File provided and stops Code execution. The meta Information includes file Size, Time of Access, -Modified and -Created. On Windows OS Systems this Parameter will also display the classic file Attributes.

> catw test.txt -a
<Path>/test.txt
Size:           1.55 KB
ATime:          YYYY-MM-DD HH:MM:SS.
MTime:          YYYY-MM-DD HH:MM:SS.
CTime:          YYYY-MM-DD HH:MM:SS.
+Archive, Indexed
-System, Hidden, Readonly, Compressed, Encrypted

Shows different Checksums for each File provided and stops Code execution. The displayed Checksums include CRC32, MD5, SHA1, SHA256 and SHA512.

> catw test.txt -m
Checksum of '<Path>/test.txt':
        CRC32:   F67C071D
        MD5:     95de18c87649e804c15ccdd73ae6eddc
        SHA1:    cecdcba1cd12a9fdfdb32a1aa1bc40bdb9b1261c
        SHA256:  1d4bf9f69b9d1529a5f6231b4edeba61a86deeebf00060c4de6f67f0c4e3b711
        SHA512:  db9a71ef22360f171daa4e4aed033337f4f97812baf38a51bdd6ed64b5c2a0d4a5c4152e20b68f881df9e5f1087c1293853eac13f928b845b9b71c3ce517c9e3

Only displays Sequences of printable Characters that exceed a certain Length. This Length can be configured using the strings_minimum_sequence_length element in the config menu (--config, --config). The Delimeter of different Sequences on the same Line can be configured using the strings_delimeter element in the config menu.

> catw --strings test.bin
/lib64/ld-linux-x86-64.so.2
__cxa_finalize
__libc_start_main
puts
libc.so.6
GLIBC_2.2.5
GLIBC_2.34
...

Decodes a Base64 encoded Input and continues Code execution with the decoded Text. This Parameter will be used before most other Arguments such that other Parameters will be used on the decoded Text. This means a Base64 encoded Input is expected and neccessary.

> echo SGVsbG8gV29ybGQ= | catw - --b64d
Hello World

Encodes a given Text in Base64. This Parameter will be used after most other Arguments such that other Parameter will be used on the plain Text beforehand.

> echo Hello World | catw - --b64e
SGVsbG8gV29ybGQ=

Evaluates simple mathematical Expressions within any given Text. The mathematical Expressions may consist of paranthesis, Operators including Modulo (%) and Exponential (**), as well as any Number in Hexadecimal, Decimal, Octal or Binary. The evaluated Value of the Expression will by default be inserted back into the Position of the Text where the Expression was found. In the uppercase Variant of the Parameter any non-mathematical Text will be stripped thus only evaluated Expressions will remain. On Error The Expression will evaluate to '???'.

> echo Calculate: (5 * 0x10 * -0b101) % (0o5 ** 2) ! | catw - --eval
Calculate: 0 !
> echo Calculate: (5 * 0x10 * -0b101) % (0o5 ** 2) ! | catw - --EVAL
0

If a Line only contains a hexadecimal Number this Parameter will append the equivalent Value in Binary, Octal and Decimal. Negative Numbers are allowed. Numbers are allowed to start with the Prefix 0x. When using the uppercase Variant (--HEX) the Numbers will not include their Prefixes (like 0x, 0b or 0o).

> catw test.txt --hex
FF [Bin: 0b11111111, Oct: 0o377, Dec: 255]
0x610 [Bin: 0b11000010000, Oct: 0o3020, Dec: 1552]
> catw test.txt --HEX
FF [Bin: 11111111, Oct: 377, Dec: 255]
0x610 [Bin: 11000010000, Oct: 3020, Dec: 1552]

If a Line only contains a decimal Number this Parameter will append the equivalent Value in Binary, Octal and Hexadecimal. Negative Numbers are allowed. When using the uppercase Variant (--DEC) the Numbers will not include their Prefixes (like 0x, 0b or 0o).

> catw test.txt --dec
255 [Bin: 0b11111111, Oct: 0o377, Hex: 0xff]
1552 [Bin: 0b11000010000, Oct: 0o3020, Hex: 0x610]
> catw test.txt --DEC
255 [Bin: 11111111, Oct: 377, Hex: ff]
1552 [Bin: 11000010000, Oct: 3020, Hex: 610]

If a Line only contains an octal Number this Parameter will append the equivalent Value in Binary, Decimal and Hexadecimal. Negative Numbers are allowed. Numbers are allowed to start with the Prefix 0o. When using the uppercase Variant (--OCT) the Numbers will not include their Prefixes (like 0x, 0b or 0o).

> catw test.txt --oct
0o377 [Bin: 0b11111111, Dec: 255, Hex: 0xff]
3020 [Bin: 0b11000010000, Dec: 1552, Hex: 0x610]
> catw test.txt --OCT
0o377 [Bin: 11111111, Dec: 255, Hex: ff]
3020 [Bin: 11000010000, Dec: 1552, Hex: 610]

If a Line only contains a binary Number this Parameter will append the equivalent Value in Octal, Decimal and Hexadecimal. Negative Numbers are allowed. Numbers are allowed to start with the Prefix 0b. When using the uppercase Variant (--BIN) the Numbers will not include their Prefixes (like 0x, 0b or 0o).

> catw test.txt --bin
11111111 [Oct: 0o377, Dec: 255, Hex: 0xff]
0b11000010000 [Oct: 0o3020, Dec: 1552, Hex: 0x610]
> catw test.txt --BIN
11111111 [Oct: 377, Dec: 255, Hex: ff]
0b11000010000 [Oct: 3020, Dec: 1552, Hex: 610]

Displays a BinaryViewer for each File passed in. Special Characters like NewLine or BackSpace will be displayed as specific readable Chars if the Font and the Encoding do support that Behaviour.

> catw test.txt --binview
<Path>\test.txt:
Address  00       01       02       03       04       05       06       07       08       ... # Decoded Text
00000000 01000011 01100001 01110100 01011111 01010111 01101001 01101110 00100001 00001010 ... # C a t _ W i n ! ␤

Displays a Hexviewer for each File passed in. Special Characters like NewLine or BackSpace will be displayed as specific readable Chars if the Font and the Encoding do support that Behaviour. When using the uppercase Variant of this Parameter (--HEXVIEW) the hexadecimal Numbers within the Hexviewer will also be uppercase.

> catw test.txt --hexview
<Path>\test.txt:
Address  00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F # Decoded Text
00000000 48 65 6c 6c 6f 20 57 6f 72 6c 64 20 46 72 6f 6d # H e l l o   W o r l d   F r o m
00000010 20 43 61 74 21 0a                               #   C a t ! ␤
> catw test.txt --HEXVIEW
<Path>\test.txt:
Address  00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F # Decoded Text
00000000 48 65 6C 6C 6F 20 57 6F 72 6C 64 20 46 72 6F 6D # H e l l o   W o r l d   F r o m
00000010 20 43 61 74 21 0A                               #   C a t ! ␤

Opens a simple Editor to write/edit the Content of any provided File one by one. Not-existing Files will be opened first and existing Ones will be able to be edited after that. The Editor will not save Changes automatically. Files will be saved with the text Encoding defined by enc=X, enc꞉X. Note that ^c (Ctrl-c) is reserved for the KeyboardInterrupt meaning that it will stop the entire Program instantly. The Auto-Indendation Feature can be turned on in the config menu using the editor_auto_indent element. The Indendation when using Auto-Indendation can be configured in the config menu (--config, --config) using editor_indentation. On Windows this Feature uses the windows-curses Module. The currently supported Key bindings are as follows:

Key(s) default behaviour shift click control click alt click
Arrows move cursor by char move cursor by char move cursor by word scroll window by char
Page Up/Down move cursor by page move cursor by page move cursor by page scroll window by page
Home/Pos move cursor to start of line move cursor to start of line move cursor to start of file scroll window to start of file
End move cursor to end of line move cursor to end of line move cursor to end of file scroll window to end of file
Tab insert a tab or
indent on empty line
decrease indent - -
Enter write newline write newline write newline -
Backspace delete char on the left delete char on the left delete word on the left delete char on the left
Delete delete char on the right delete char on the right delete word on the right delete char on the right
Undo/^Z - - undo an action -
Redo/^Y - - redo an action -
Save/^S - - save changes save changes
Jump/^E - - prompt to jump to specific line -
Find/^F - - prompt to search in the file -
Background/^B - - put the editor in the background
(UNIX only)
-
Reload/^R - - prompt to reload the file -
Insert/^I - - Insert a Byte Sequence -
Quit/^Q - - close editor
(prompt to save, if neccessary)
-
Interrupt/^C - - interrupt program -

Opens a simple Hex-Editor to write/edit the Content of any provided File one by one. Not-existing Files will be opened first and existing Ones will be able to be edited after that. The Editor will not save Changes automatically. Note that ^c (Ctrl-c) is reserved for the KeyboardInterrupt meaning that it will stop the entire Program instantly. The displayed Columns per Row can be configured in the config menu (--config, --config) using hex_editor_columns. On Windows this Feature uses the windows-curses Module. The currently supported Key bindings are as follows:

Key(s) default behaviour shift click control click alt click
Arrows move cursor by byte move cursor by byte move cursor multiple bytes -
Page Up/Down move cursor by page move cursor by page move cursor by page -
Home/Pos move cursor to start of line move cursor to start of line move cursor to start of file -
End move cursor to end of line move cursor to end of line move cursor to end of file -
0-9 & A-F edit the current byte - - -
< insert a new byte to the left - - -
> & ␣ insert a new byte to the right - - -
Backspace reset current byte reset current byte remove current byte reset current byte
Delete reset current byte reset current byte remove current byte reset current byte
Save/^S - - save changes save changes
Jump/^E - - prompt to jump to a specific byte -
Find/^F - - prompt to search a byte(-sequence) in the file -
Background/^B - - put the hex-editor in the background
(UNIX only)
-
Reload/^R - - prompt to reload the file -
Insert/^I - - Insert a Text Sequence -
Quit/^Q - - close hex-editor
(prompt to save, if neccessary)
-
Interrupt/^C - - interrupt program -

Page through the File Contents Step by Step. Each Step the Output is paused until User Interaction. The first Step always fills the entire Screen. The following Steps have the Size as defined by the config Element more_step_length. Display the available Commands by entering ? or h or help.

> catw file -M
line 1
line 2
...
line 29
> -- More ( 6%) --
line 30
...
> -- More (11%) --
...
> catw file -M
...
> --More (10%) -- ?
H HELP       display this help message
Q QUIT       quit
N NEXT       skip to next file
L LINE       display current line number
D DOWN <x>   step x lines down
S SKIP <x>   skip x lines
J JUMP <x>   jump to line x
...

Opens the given Files in Binary Mode. Prints the Output as Raw Binary to the stdout-Stream. The only valid Parameters in Combination to -b, --raw are --b64e, --b64e, --b64d, --b64d and --strings, --strings.

> catw img.png > copy.png
UnicodeEncodeError: 'charmap' codec can't encode character '\ufffd' in position 0: character maps to <undefined>
...
> catw img.png -R > copy.png
(works but copy.png is corrupted)
> catw img.png --raw > copy.png

> catw img.png --b64e --raw | catw - --b64d --raw > copy.png

Copies the entire Output to the Clipboard additionally to printing it to the Stdout Stream.

When providing file Patterns or entire Directories cat_win will find every File including those set to hidden (e.g. on Windows OS). However Dotfiles, meaning Files that start with a literal Dot, will not be found by Default. Using this Parameter cat_win will also include Dotfiles.

> catw * -F
found FILE(s):
        12.35 KB   <Path>/CHANGELOG.md
        1.06 KB    <Path>/LICENSE
        15.07 KB   <Path>/README.md
...
> catw * -F --dot
found FILE(s):
        969.0 B    <Path>/.gitignore
        12.35 KB   <Path>/CHANGELOG.md
        1.06 KB    <Path>/LICENSE
        15.07 KB   <Path>/README.md
...

By default the User is being prompted when a non-plaintext File is being encountered as to if the File should be opened in Binary or not. Using --plain-only these Files will be automaticaly skipped. Note that these Prompts are not descriptive enough to say that a File can only be opened in Binary. Often the Problem is being fixed by providing another Codepage using the enc=X, enc꞉X Parameter.

By default different Colors will be used to better highlight specific Parts of the Output or make original and changed Parts of a Line more distinguishable. Using --nocolor will disable all Colors and only display the Output in plain monochrome Text.


Displays a user interactive config Menu allowing the User to change specific default parameters. Stops Code execution after finishing the Configuration. The config File will be saved to the installation Directory of cat_win which is by Default the Python directory. This means that uninstalling cat_win may result in the config File being left over. When using the Windows Executables this Parameter will have no (long term) Effect. Valid Options are:

Option Description Example Default
default_command_line custom Command Line containing Parameters
used additionally to the specific Parameters
of the Program Call
-n 'find= '
default_file_encoding the File Encoding used by Default utf-16 utf-8
large_file_size the Size (Bytes) at which a Warning occurs 1024 104857600 (100Mb)
strip_color_on_pipe indicate if the Output should be stripped of any Color false true
ignore_unknown_bytes ignore unknown bytes instead of replacing them with � true false
peek_size define the amount of lines shown by -p, --peek 10 5
strings_minimum_sequence_length set the minimum Length of a String
(for the --strings, --strings Parameter)
2 4
strings_delimeter set the Delimeter for Strings found on the same Line
(for the --strings, --strings Parameter)
| \n
editor_indentation set the Indentation used in the Editor (-!, --edit)
when pressing ↹ on an empty Line
␣ ␣ ␣ ␣
editor_auto_indent set whether the Editor (-!, --edit) should auto indent or not true false
hex_editor_columns set the amount of columns per row in the HexEditor (-#, --hexedit) 8 16
more_step_length define the Step Length used by -M, --more
a Value of 0 is equivalent to the Size/Height of the Terminal Window
5 0
unicode_escaped_echo unicode-escape the input when using -E, --echo false true
unicode_escaped_editor_search unicode-escape the Search in the Editor (-!, --edit) false true
unicode_escaped_find unicode-escape the queried Substring when using find=X, find꞉X false true
unicode_escaped_replace unicode-escape a and b when using [a,b] false true

Accepted Input for enabling a Setting: true, yes, y, 1
Accepted Input for disabling a Setting: false, no, n, 0
(Input is not case sensitive)

Displays a user interactive config Menu allowing the User to change the Colors for specific Elements and Arguments. Stops Code execution after finishing the Configuration. The config File will be saved to the installation Directory of cat_win which is by Default the Python directory. This means that uninstalling cat_win may result in the config File being left over. When using the Windows Executables this Parameter will have no (long term) Effect. Valid Options are:

Option Description
line_length the display of each line length using -l, --linelength
line_numbers the numbering of each line using -n, --number
file_prefix the file prefix using --fp, --file-prefix
line_ends the end of line marker using -e, --ends
special_chars special chars using --chr, --char
summary_message the message displayed using -f, --files/-d, --dirs/-s, --sum/-w, --wordcount/--cc, --charcount
number_evaluation the evaluated value using --eval, --EVAL
number_conversion the converted values using --bin/--oct/--dec/--hex
file_attribute_message the message containing time stamps and file size using -a, --attributes
active_file_attributes the attributes a file has set using -a, --attributes
missing_file_attributes the attributes a file has not set using -a, --attributes
checksum_message the calculated checksum of a given file using -m, --checksum
raw_viewer the output using --hexview, --HEXVIEW/--binview, --binview
found_keyword the found substring using find=X, find꞉X
found_keyword_message the message displayed when using find=X, find꞉X
matched_pattern the matched pattern using match=X, match꞉X
matched_pattern_message the message displayed when using match=X, match꞉X
substring_replacement the replaced string using [a,b]
message_information any informational message like update information
message_important any important message like large file sizes
message_warning any warning message like overwriting a file with itself

Reset the Configuration (of --config, --config) to their Default Values.

> catw --config-clear
Successfully updated config file:
   <Path>\cat.config

Reset the Configuration (of --cconfig, --cconfig) to their Default Values.

> catw --config-clear
Successfully updated config file:
   <Path>\cat.config

Delete the Config File. This will reset both --config, --config and --cconfig, --cconfig Configurations to their Default Values. The cat.config File will be erased from the System.

> catw --config-remove
The config file has successfully been removed!
> catw --config-remove
No active config file has been found.

Python uses Utf-8 to encode the Streams by default. On Windows OS the Encoding may even be Cp1252. The Encoding can be influenced externally by setting the environment Variable PYTHONIOENCODING to the desired Encoding, or setting the environment Variable PYTHONUTF8 to 1. In any case it is often useful to have the stream Encoding variable if a File for example is written in another Codepage like Utf-16. Using this Parameter allows for specific Stream Reconfiguration meaning setting the Encoding for interpreting the Streams. The Encoding used is defined by the enc=X, enc꞉X Argument. By Default Stdout and Stderr are reconfigured. Valid Streams are Stdout (--Rout), Stdin (--Rin) and Stderr (--Rerr). When encountering UnicodeErrors the Problem is most likely being fixed by using -R (or --Rout).

> catw ./CHANGELOG.md > test.txt
UnicodeEncodeError: 'charmap' codec can't encode character ...
> catw ./CHANGELOG.md --Rout > test.txt

Sets the text Encoding that is being used to read and write Files. Valid Options are defined by the Python Interpreter used (e.g. for Python3.10). The default Encoding is Utf-8. The default Encoding can be configured using the default_file_encoding element in the config menu (--config, --config).

> catw test.txt
Failed to open: <Path>\test.txt
Do you want to open the file as a binary, without parameters?
[Y/⏎] Yes, Continue       [N] No, Abort :
> catw test.txt enc=utf-16
This Text is written in Utf-16!

Defines a Literal to search for within the Text of any provided File. The Substring is unicode-escaped (\n will be interpreted as an actual Newline) if the Config Option unicode_escaped_find is set but in Case of an unicode-error the Substring will simply be used literally. When the Literal contains Whitespaces it is neccessary to encase the entire Parameter with Quotes as defined by the Terminal used. It is possible to define multiple Substrings to search for by simply providing the Parameter find=X multiple times. When using this Parameter in Uppercase the Case of the Substring will be ignored.

> catw test.txt "find=cats and"
It's raining cats and dogs!
--------------- Found [('cats and', [13, 21])] ---------------

> catw test.txt "find=CATS and"
It's raining cats and dogs!
> catw test.txt "FIND=CATS and"
It's raining cats and dogs!
--------------- Found [('CATS and', [13, 21])] ---------------

Defines a Pattern to search for within the Text of any provided File. It is possible to define multiple Patterns to match for by simply providing the Parameter match=X multiple times. The given Patterns is simply treated as a regular Expression. When using this Parameter in Uppercase the Case of the Pattern will be ignored.

> catw test.txt "match=cat.\s.{3,}"
It's raining cats and dogs!
--------------- Matched [('cat.\\s.{3,}', [13, 27])] ---------------

> catw test.txt "match=CAT.\s.{3,}"
It's raining cats and dogs!
> catw test.txt "MATCH=CAT.\s.{3,}"
It's raining cats and dogs!
--------------- Matched [('CAT.\\s.{3,}', [13, 27])] ---------------

Truncates every File by the Specifics defined. This Parameter uses the default Python slicing Mechanic and uses it on the Lines of each File. The Argument is valid by defining trunc=<start>:<stop> or trunc=<start>:<stop>:<step>

> catw test.txt trunc=5:-5:2
 6) Line 6
 8) Line 8
10) there are 5 more Lines following this one

Replaces the Substring defined by a with the Substring b in every Line of Every File. The Substrings a and b are unicode-escaped (\n will be interpreted as an actual Newline) if the Config Option unicode_escaped_replace is set but in Case of an unicode-error the Substrings will simply be used literally. Comma (,) can be escaped using \, despite it not being a valid unicode-escape Sequence. When one of the Substrings contains Whitespaces it is neccessary to encase the entire Parameter with Quotes as defined by the Terminal used.

> catw test.txt "[\,,X]" "[\\,/]"
This is a comma: X
This is a Backslash: /

Similiar to the trunc=X꞉Y, trunc꞉X꞉Y parameter this Argument is used on each Line individually. Every Line is being cut down as specified by the Elements within the Argument [<start>:<stop>:<step>].

> catw test.txt [2::2]
2468acegikmoqsuwy