Created
April 4, 2013 15:04
-
-
Save anonymous/5311155 to your computer and use it in GitHub Desktop.
Automatically git rm if file directory is a git repository.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding = utf-8 | |
#Save to ~/rm.py(f.e.), add alias(f.e. alias rm="python ~/rm.py"), and enjoy it! | |
import sys | |
import os | |
args = sys.argv[1:] | |
filename = "" | |
fn_pos = 0 | |
for arg in args: | |
if arg[:1] == "-": | |
continue | |
filename = arg | |
fn_pos = args.index(arg) | |
break | |
runarg = "/bin/rm" | |
for arg in args: | |
runarg += " %s" % arg | |
if os.path.isdir(os.path.join(os.getcwd(), '.git')): | |
os.system("git rm --cached %s" % filename) | |
os.system(runarg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment