Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Git on Windows Scripts [Python+AHK]
Index -> General Programming
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Zren




PostPosted: Mon Jul 11, 2011 7:17 pm   Post subject: Git on Windows Scripts [Python+AHK]

Pushing stuff to git is fairly annoying. At least for me. Compared to Ctrl+s, it's painful. Most of the time I don't even have the git shell open, or I have to use the cd to locate the file. Leaving the shell open is fine, but break workflow as you have to change windows.

Anyways, I checked out the link that opened the shell, and found out an argument for sh.exe that'll execute code. From there, I moved it to a python script. It probably could all go in AutoHotKey (which I use to speed things up even more), but I'm nowhere near fluent in it.

gitUpdate.py
/d/ = D:\ drive for those wondering.
Python:

#!/usr/bin/env python
import os
p_cmd = 'C:\\Windows\\SysWOW64\\cmd.exe'
p_sh = 'C:\\Program Files (x86)\\Git\\bin\\sh.exe'
p_project = '/d/Code/Python/pyTactics/'
project_remote = 'origin'
project_repo = 'master'
msg = raw_input("Update msg: ")
args = '''/c ""%s" --login -i -c "cd %s;git init;git add *;git commit -m '%s';git push %s %s;""''' % (p_sh, p_project, msg, project_remote, project_repo)
os.execv(p_cmd, list(args.split(" ")))


AutoHotKey Script (gitBind.ahk)
I bind the CapsLock key as it's easily the most useless key ever. It's also big.
code:

Capslock::Run open "D:\Code\Python\gitUpdate.py"


Basically your workflow is now:
<CapsLock>
*New window takes focus*
Enter update message
<Enter>
*Window disappears*
Back to coding.
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: