Created
March 4, 2010 00:53
-
-
Save dotemacs/321268 to your computer and use it in GitHub Desktop.
This file contains 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
;; creates .gitignore file | |
;; | |
;; added a check, so that if a .gitignore exists already it doesn't overwrite it | |
(defun gitignore(dir) | |
"create .gitignore file in a directory supplied | |
populating it with the patterns/files" | |
(interactive "DDirectory name: ") | |
(setq ignore-patterns | |
;; modify patterns/files below as per your need | |
'("*~" | |
"log/*.log" | |
"tmp/**/*" | |
"config/database.yml" | |
"db/*.sqlite3")) | |
(setq .gitignore (concat (file-name-as-directory dir) ".gitignore")) | |
(if (file-exists-p .gitignore) | |
(progn | |
(message "%s exists already, nothing new was added" .gitignore) | |
(find-file .gitignore)) | |
(progn | |
(switch-to-buffer .gitignore) | |
(while ignore-patterns | |
(insert-string (concat (car ignore-patterns) "\n")) | |
(setq ignore-patterns (cdr ignore-patterns))) | |
(message "%s created" .gitignore)))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment