Sometimes the text files are downloaded to the local for viewing. The text reader that comes with the system generally has no problem reading small files.
When encountering large files, there will be some pain points:
- Large file size, slow loading
- When it is closed and then opened, it will start reading from the initial position again
To solve this problem, I wrote a command-line text reader in Node.js, which supports:
- Support encoding UTF-8, GBK
- Support memory history files
- Support for remembering the last read point of a file
1. Installation
Open source Node.js project, just pull down the source code and run it directly.
git clone [email protected]:swlws/ctr.git
cd ctr
npm install
npm link
After the installation is complete, the command line input ctr
will have the following output, that is, the installation is successful:
read file via cmd command line interface
ctr help: show help info. eg: ctr help
ctr add:
add directory. eg: ctr add file_dir
add one file. eg: ctr add file_path
ctr rm:
remove all file. eg: ctr rm all
remove one file. eg: rm file_id
ctr set: set app attr.
set page size. eg: set size 100
set encode. eg: ctr set encode gbk. default value is utf-8
ctr config: show app config
ctr ID: show one file
when read one file
u: previous page
n: next page
entry: next page
Two, use
add a text
ctr add /root/a.txt
Add all text in the directory
ctr add /root
Show added text
ctr list
ID Name Path
ad41372694dacab9012b9e2178e3ef53 abc.txt /root/abc.txt
c23f22d7034cadb93edfa9062f609979 def.txt /root/def.txt
delete a text
ctr rm ad41372694dacab9012b9e2178e3ef53
delete all text
ctr rm all
show single text
ctr ad41372694dacab9012b9e2178e3ef53
- Previous page: Press the u key
- Next page: Press the d key, or press the Enter key