The command you posted didn't work for me. It didn't copy the selected text.
Try this one: #!/usr/bin/env ruby sel = STDIN.read.chomp if ( sel =~ /^\?{(.+)\?}$/) print "\left\{#{$1}\right\}"; elsif ( sel =~ /^(.)(.+)(.)$/) print "\left#{$1}#{$2}\right#{$3}"; end
It will do {abc} -> \left{abc\right} {abc} -> \left{abc\right} and [abc] -> \left[abc\right] where in the latter case also other characters than [ ] will work.
Ruben