|
@@ -220,6 +220,24 @@ nlfor() {
|
220
|
220
|
| fixnl
|
221
|
221
|
}
|
222
|
222
|
|
|
223
|
+nljoin() {
|
|
224
|
+ #
|
|
225
|
+ # Join lines with $1
|
|
226
|
+ #
|
|
227
|
+ # Shorthand for commonly used tr syntax. Example:
|
|
228
|
+ #
|
|
229
|
+ # $ { echo foo; echo bar; } | nljoin :
|
|
230
|
+ #
|
|
231
|
+ # is almost like `tr '\n' :` except that it is a bit easier
|
|
232
|
+ # to type and fixes the annoying problem with extraneous
|
|
233
|
+ # newline/colon at the end of final string.
|
|
234
|
+ #
|
|
235
|
+ local char=$1
|
|
236
|
+ tr '\n' "$char" \
|
|
237
|
+ | sed "s/$char*$//" \
|
|
238
|
+ | fixnl -c
|
|
239
|
+}
|
|
240
|
+
|
223
|
241
|
xop() {
|
224
|
242
|
#
|
225
|
243
|
# Common clipboard operations with fixnl() on top
|