0

I am running GNOME 3 and am trying to write a script in a desktop file that redirects mailto links to Yahoo! webmail.

Stuff like these pages helped me a bit, but I still cannot get a working script.

My goal is to get something like "mailto:Dan Hoang <ntg255@gmail.com>" to become "mailto:ntg255@gmail.com" and pass it on to Epiphany.

Script so far:

Exec=env qs='echo $1 | sed 's/mailto:/To=/' | sed -e 's/\(To==1&\).*\( *@=2&\)/\1\2/' | sed 's/\?subject=/\&Subject=/'' epiphany %U --new-tab http://compose.mail.yahoo.com/?$qs&#8221;

Notes: Script works for mailto links with only e-mail addresses without the sed -e 's/\(To==1&\).*\( *@=2&\)/\1\2/' part. This part was my attempt at removing the name. Also, the %U attached to epiphany serves no purpose; it is only there to allow it to be set as a default application.

Community
  • 1
  • 1
Dan Hoang
  • 9
  • 1
  • You don't need to run `sed` repeatedly. Just give multiple `-e` options so it performs all the operations. – Barmar May 07 '15 at 00:33
  • You're using the same quote delmiter around the argument to `sed` as you are around the entire `qs=` parameter. That probably won't work. – Barmar May 07 '15 at 00:35

1 Answers1

0

This would do:

echo "mailto:Dan Hoang <ntg255@gmail.com>" | awk '/mailto:/{gsub(/[<>]/,"");$0="mailto:"$NF}1'
mailto:ntg255@gmail.com

Another solution:

echo "mailto:Dan Hoang <ntg255@gmail.com>" | awk -F"mailto" 'NF>1{split($2,a,"<|>");$0=FS a[2]}1'
mailtontg255@gmai

l.com

Jotne
  • 40,548
  • 12
  • 51
  • 55