Re: Trimming lines with a filter

2024-04-10 Thread Rich Siegel
On 10 Apr 2024, at 10:49, Christopher Finazzo wrote:

> A number of my projects standardize on 80 characters per line. I have tried
> to use Process Lines to simplify this process:
>
> 1) Text > Process Lines Containing...
> 2) Check the Grep checkbox
> 3) Use the following pattern to target all lines with 80 or more characters:
>
> .{{0,79}}
>
> I've done it enough times that it would be useful to have this run as a
> filter so that I don't need to invoke it manually each time.

You could create a text factory with a single "Process Lines Containing" step, 
and then put that in BBEdit's "Text Filters" support folder; seems like that 
would do the job. (You can shorten the path by using "Apply Text Transform" to 
test the operation, then employ the "Save as Text Factory" button.)

Enjoy,

R.

-- 
Rich Siegel Bare Bones Software, Inc.
  

Someday I'll look back on all this and laugh... until they sedate me.

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or believe that the application isn't working correctly, please email 
"supp...@barebones.com" rather than posting here. Follow @bbedit on Mastodon: 

--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/523D7AA8-C43B-41C5-BBD7-D8BA9D05EE29%40barebones.com.


Trimming lines with a filter

2024-04-10 Thread Christopher Finazzo
A number of my projects standardize on 80 characters per line. I have tried 
to use Process Lines to simplify this process:

1) Text > Process Lines Containing...
2) Check the Grep checkbox
3) Use the following pattern to target all lines with 80 or more characters:

.{{0,79}}

I've done it enough times that it would be useful to have this run as a 
filter so that I don't need to invoke it manually each time. However, a 
(admittedly shitty) first pass with ChatGPT to wrap these steps in a script 
returns a different result.

An example script is shown below.

#!/bin/bash

# Read input line by line
while IFS= read -r line; do
# Delete characters longer than 80 characters
modified_line=$(echo "$line" | sed -E 's/.{81,}//g')
  echo "$modified_line"
done

Is GPT just dumb or am I missing something obvious?

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or believe that the application isn't working correctly, please email 
"supp...@barebones.com" rather than posting here. Follow @bbedit on Mastodon: 

--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/c88577bf-3041-4c98-9819-e0f21823215bn%40googlegroups.com.