Skip to content

Instantly share code, notes, and snippets.

@MAGANER
Created December 8, 2021 10:36
Show Gist options
  • Save MAGANER/2e5f68071028e023cfb45886ecd15069 to your computer and use it in GitHub Desktop.
Save MAGANER/2e5f68071028e023cfb45886ecd15069 to your computer and use it in GitHub Desktop.
Little python script to generate .gitignore file for c++ projects.
import os
_all = os.listdir(os.getcwd())
files = list(filter(lambda n: os.path.isfile(n),_all))
def is_cpp(file):
ext = [".cpp",".hpp",".h",".c"]
for e in ext:
if file.endswith(e):
return True
return False
not_cpp_stuff = list(filter(lambda n: not is_cpp(n),files))
with open(".gitignore","w") as f:
for n in not_cpp_stuff:
f.write(n+"\n")
f.write(".vs/") #for visual studio stuff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment