Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add sed-remove-newlines abbreviation #835

Merged
merged 1 commit into from
Oct 27, 2023
Merged

Conversation

LucasLarson
Copy link
Owner

this version of the sed command:

  • uses no exclamation point (!),1 obviating the need to modify $LBUFFER2
  • escapes a newline (\n is saved here as \\n)3 so that when printed to the console, the newline recipe appears correctly as \n4 rather than as a mid-command linebreak5

Footnotes

  1. sed -e ':a' -e 'N' -e '$! b a' -e 's/\n//g' performs the same task, but uses an exclamation point (!), which requires modifying $LBUFFER2

  2. olets/zsh-abbr #84 2

  3. abbr -g "sed -n 'H;${x;s/\\n//gp;}'"

  4. sed -n 'H;${x;s/\n//gp;}'

  5. sed -n 'H;${x;s/⏎//gp;}' # such that ⏎ is a literal newline

this version of the command:
- uses no exclamation point (`!`),¹ obviating the need to modify
  `$LBUFFER`²
- escapes a newline (`\n` is saved here as `\\n`)³ so that when
  printed to the console, the newline recipe appears correctly as `\n`⁴
  rather than as a mid-command linebreak⁵

---
1. `sed -e ':a' -e 'N' -e '$! b a' -e 's/\n//g'` performs the same task,
   but uses an exclamation point (`!`), which requires modifying
   `$LBUFFER`²
2. olets/zsh-abbr#84 (comment)
3. `abbr -g "sed -n 'H;${x;s/\\n//gp;}'"`
4. `         sed -n 'H;${x;s/\n//gp;}'`
5. `         sed -n 'H;${x;s/⏎//gp;}'`

Signed-off-by: Lucas Larson <[email protected]>
@LucasLarson LucasLarson merged commit ec0058d into main Oct 27, 2023
6 checks passed
@LucasLarson LucasLarson deleted the sed-remove-newlines branch October 27, 2023 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant