From ec0058df92fdbb31341e175d3b04576db9c44895 Mon Sep 17 00:00:00 2001 From: Lucas Larson Date: Fri, 27 Oct 2023 14:06:36 -0400 Subject: [PATCH] feat: add `sed`-remove-newlines abbreviation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. https://github.com/olets/zsh-abbr/issues/84#issuecomment-1475075037 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 --- .config/zsh-abbr/user-abbreviations | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.config/zsh-abbr/user-abbreviations b/.config/zsh-abbr/user-abbreviations index b8de0e6efb..9882339841 100644 --- a/.config/zsh-abbr/user-abbreviations +++ b/.config/zsh-abbr/user-abbreviations @@ -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'