QiangF / autokey

Automatically exported from code.google.com/p/autokey
GNU General Public License v3.0
0 stars 0 forks source link

Feature enhancement: Allow regex variables in phrase expansion #195

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hello, I'd like to use AutoKey to automate some bash commands, like e.g.:

sudo rctc restart XXX && tail -f /srv/tc/XXX/logs/log4java.log

where XXX can be one of the list of applications. If you wonder why I don't 
just create simple bash script, it's because there are a lot of servers I need 
to do these commands and it would be hard to keep them all in sync.

I imagine that I could create AutoKey phrase like this:

phrase: sudo rctc restart $1 && tail -f /srv/tc/$1/logs/log4java.log
trigger: restart-([a-z]+[0-9])

Then I would type restart-XXX1 and it would expand into sudo rctc restart XXX1 
&& tail -f /srv/tc/XXX1/logs/log4java.log

I think that a lot of people could benefit from this feature. Is it possible?

If it's not very complicated, I could take a look at it myself. Would you 
accept patch for this feature?

Thanks.

Original issue reported on code.google.com by adam.ziv...@gmail.com on 1 May 2012 at 7:41

GoogleCodeExporter commented 9 years ago
It's an interesting idea. I think a less invasive way of doing this would be to 
use the script API. One could add a function to the script API which lets the 
script retrieve the abbreviation/word that triggered the running of the script. 
You could then use that value and extract whatever info you need to construct 
the right string to send to the keyboard. If you want to have a go I'd be happy 
to accept a patch, otherwise it'll go on my to-do list.

Original comment by cdekter on 2 May 2012 at 9:16

GoogleCodeExporter commented 9 years ago
Why not just use bash aliases? For example, I have one called restsmb that runs 
"sudo service smbd restart". You could create restXXX and restYYY that runs 
your "sudo rctc..." commands.

Original comment by ThomasM...@gmail.com on 18 Dec 2012 at 6:05

GoogleCodeExporter commented 9 years ago
> If you wonder why I don't just create simple bash script, it's because there 
are a lot of servers I need to do these commands and it would be hard to keep 
them all in sync.

Original comment by adam.ziv...@gmail.com on 18 Dec 2012 at 9:01

GoogleCodeExporter commented 9 years ago
A reference to the trigger would be useful to do conversions such as kg to lbs
trigger: (d*)kg 
the number captured by the regex in say 100kg can then be used in calculations 
(say x=x*2.2) to give a phrase when expanded 100 kg = 220 pounds

Original comment by phuttenc...@gmail.com on 9 Feb 2014 at 3:13