Turn one sed command into a Textmate reusable command

I have 7 lines of text:

a
b
c
d
e
f
g

Now I want to add characters to the end of each line, so that in the end:

a,
b,
c,
d,
e,
f,
g,

I found that I can use the sed command and run my selection through sed using the "Filter through" command in Textmate

sed 's/$/,/'

Now one question remains: how to turn this into a Textmate command that introduces some input (so that it knows which text to add)?

(My attempts to do this were unsuccessful)

+5
source share
4 answers

Put this in the command complete with text, it will add everything that is on the clipboard to the end of all the selected lines:

#!/bin/bash
if [[ $(pbpaste|wc -l) -eq 0 ]]
    then r=`pbpaste`
    sed 's/$/'$r'/'
    else sed 's/$/,/'
fi

, , .

Edit:

, , , , ​​ :

#!/bin/bash
r=$(CocoaDialog inputbox --title "String to be appended to EOL" \
   --informative-text "Enter string:" \
   --button1 "Okay" --button2 "Cancel")

[[ $(head -n1 <<<"$r") == "2" ]] && exit_discard

r=$(tail -n1 <<<"$r")

sed "s/$/$r/"
+3

" ". , , , .

+2

#!/bin/bash
sed 's/$/,/'


, .

, .

+2

"/", :

  • / ,
  • ""
  • " "
  • "" '$' ( )
  • "" ',' (, )
  • hold Option, " " " "

. , '$' '^', .

+2

All Articles