Skip to content

Commit

Permalink
feat: add sed-remove-newlines abbreviation
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
LucasLarson committed Oct 27, 2023
1 parent 8afccf9 commit ec0058d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .config/zsh-abbr/user-abbreviations
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ abbr --global prntf='printf'
abbr --global prtinf='printf'
abbr --global rpintf='printf'

## sed
abbr --global srn='command sed -n -e '\''H'\'' -e '\''$ {'\'' -e '\''x'\'' -e '\''s/\\n//gp'\'' -e '\''}'\'''

## soak
abbr --global saok='soak'
abbr --global 'c/saok'='cd -- "${HOME%/}"/c/soak'
Expand Down

0 comments on commit ec0058d

Please sign in to comment.