Jump to content
Sign in to follow this  
Bhishan

Workflow to replace substring from the copied text

Recommended Posts

 

 

I was trying to write an Alfred workflow to replace a single letter/number (or substring) from the copied text.

 

Here is what I have done:

 

query=$1
old_new=($query)

old=${old_new[0]}
new=${old_new[1]}

copied=$(pbpaste)


changed=${copied/$old/$new}


echo -n $changed

 

Here is the link to my workflow in github:  https://github.com/bhishanpdl/Shared/blob/master/Alfred_questions/replace.alfredworkflow?raw=true

 

But,  this workflow is not working for MULTI-LINE .

 

 

How to fix the workflow?

 

Example test

==========

s = 'hello'

print(s[0])

 

After running the command   "replace 0 1"

 

I would like to have:

    

s = 'hello'

print(s[1])

 

 

 

 

 

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  
×
×
  • Create New...