Guest User

Untitled

a guest
May 20th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. ;; creates .gitignore file
  2. ;;
  3. ;; added a check, so that if a .gitignore exists already it doesn't overwrite it
  4.  
  5. (defun gitignore(dir)
  6. "create .gitignore file in a directory supplied
  7. populating it with the patterns/files"
  8. (interactive "DDirectory name: ")
  9. (setq ignore-patterns
  10. ;; modify patterns/files below as per your need
  11. '("*~"
  12. "log/*.log"
  13. "tmp/**/*"
  14. "config/database.yml"
  15. "db/*.sqlite3"))
  16. (setq .gitignore (concat (file-name-as-directory dir) ".gitignore"))
  17. (if (file-exists-p .gitignore)
  18. (progn
  19. (message "%s exists already, nothing new was added" .gitignore)
  20. (find-file .gitignore))
  21. (progn
  22. (switch-to-buffer .gitignore)
  23. (while ignore-patterns
  24. (insert-string (concat (car ignore-patterns) "\n"))
  25. (setq ignore-patterns (cdr ignore-patterns)))
  26. (message "%s created" .gitignore))))
Add Comment
Please, Sign In to add comment