commit 6131d1ae07f5af71f2df14a5f82a9e64b7ea5ebe
parent 2b2bccd0b6c2b5c05906a10fd1d4fecc8ea99cc9
Author: Friedel Schön <[email protected]>
Date: Thu, 8 Aug 2024 11:58:01 +0200
update help-message
Diffstat:
3 files changed, 41 insertions(+), 28 deletions(-)
diff --git a/README.md b/README.md
@@ -6,8 +6,7 @@
- Interactively select lines from a text file using a curses-based interface.
- Save selected lines to an output file.
-- Execute commands with the selected lines as arguments.
-- Flexible options for command execution, including passing selected lines as arguments, replacing placeholders in commands, or executing commands for each selected line.
+- Execute commands with the selected lines as input.
## Installation
@@ -17,19 +16,22 @@ To build `textselect` from source, you'll need a C compiler and the `ncurses` li
git clone https://github.com/friedelschoen/textselect.git
cd textselect
make
+make PREFIX=... install
```
## Usage
```sh
-textselect [-hvxil] [-o output] <input> [command [args...]]
+textselect [-hnv0] [-o output] <input> [command [args...]]
```
### Options
- `-h`: Display the help message and exit.
-- `-v`: Invert the selection of lines.
+- `-n`: Keep empty lines which are not selectable.
- `-o output`: Specify an output file to save the selected lines.
+- `-v`: Invert the selection of lines.
+- `-0`: Print selected lines delimited by a NUL-character.
### Navigation and Selection Keys
@@ -42,22 +44,25 @@ textselect [-hvxil] [-o output] <input> [command [args...]]
### Examples
```sh
-# Interactively select lines from input.txt and save the selected lines to output.txt
-textselect -o output.txt input.txt
+# most simple example, select couple lines from a text-file and print it to the terminal afterwards
+textselect input.txt
+
+# select couple lines from a text-file and save it to a text-file
+textselect -o output.txt
-# Interactively select lines from input.txt and pass the selected lines as arguments to the sort command
-textselect input.txt sort
+# select couple lines from a text-file and pass these to `lolcat` for some funny output
+textselect input.txt lolcat
-# Interactively select lines from input.txt and execute the echo command for each selected line, replacing {} with the selected line
-textselect -i input.txt echo {}
+# select couple lines from a command and print it to the terminal afterwards (choosing from installed packages in Void Linux)
+textselect <(xbps-query -l)
-# Interactively select lines from input.txt and execute the echo command for each selected line
-textselect -l input.txt echo
+# select couple lines from a command and execute command with lines as arguments (removing unnecessary packages in Void Linux)
+textselect <(xbps-query -m) xargs xbps-remove
```
## License
-This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
+This project is licensed under the zlib License. See the [LICENSE](LICENSE) file for details.
## Contributing
diff --git a/textselect.1 b/textselect.1
@@ -3,7 +3,7 @@
textselect \- Interactively select lines from a text file and optionally execute a command with the selected lines.
.SH SYNOPSIS
.B textselect
-.RB [ \-hvx ]
+.RB [ \-hnv0 ]
.RB [ \-o \ output ]
.I input
.I [command [args...]]
@@ -15,11 +15,17 @@ allows users to interactively select lines from a text file. The selected lines
.B \-h
Display this help message and exit.
.TP
-.B \-v
-Invert the selection of lines.
+.B \-n
+Keep empty lines which are not selectable.
.TP
.B \-o \fIoutput\fR
Specify an output file to save the selected lines.
+.TP
+.B \-v
+Invert the selection of lines.
+.TP
+.B \-0
+Print selected lines delimited by a NUL-character
.SH NAVIGATION AND SELECTION KEYS
.TP
.B UP, LEFT
@@ -38,20 +44,22 @@ Select or deselect the current line.
Quit the selection interface.
.SH EXAMPLES
.TP
-.B textselect \-o output.txt input.txt
-Interactively select lines from \fIinput.txt\fR and save the selected lines to \fIoutput.txt\fR.
+.B textselect input.txt
+most simple example, select couple lines from a text-file and print it to the terminal afterwards
+.TP
+.B textselect -o output.txt
+select couple lines from a text-file and save it to a text-file
.TP
-.B textselect input.txt sort
-Interactively select lines from \fIinput.txt\fR and pass the selected lines as arguments to the \fBsort\fR command.
+.B textselect input.txt lolcat
+select couple lines from a text-file and pass these to `lolcat` for some funny output
.TP
-.B textselect \-i input.txt echo \{\}
-Interactively select lines from \fIinput.txt\fR and execute the \fBecho\fR command for each selected line, replacing \{\} with the selected line.
+.B textselect <(xbps-query -l)
+select couple lines from a command and print it to the terminal afterwards (choosing from installed packages in Void Linux)
.TP
-.B textselect \-l input.txt echo
-Interactively select lines from \fIinput.txt\fR and execute the \fBecho\fR command for each selected line.
+.B textselect <(xbps-query -m) xargs xbps-remove
+select couple lines from a command and execute command with lines as arguments (removing unnecessary packages in Void Linux)
.SH SEE ALSO
-.BR sort (1),
-.BR echo (1)
+.BR xargs (1),
.SH AUTHOR
Written by Friedel Schon.
.SH BUGS
diff --git a/textselect.c b/textselect.c
@@ -40,10 +40,10 @@ static void help(void) {
"\n"
"Options:\n"
" -h Display this help message and exit\n"
- " -v Invert the selection of lines\n"
" -n Keep empty lines which are not selectable\n"
" -o output Specify an output file to save the selected lines\n"
- " -0 Print selected lines demilited by NUL-character\n"
+ " -v Invert the selection of lines\n"
+ " -0 Print selected lines delimited by a NUL-character\n"
"\n"
"Navigation and selection keys:\n"
" UP, LEFT Move the cursor up\n"