Skip to content

Instantly share code, notes, and snippets.

@ejbs
Created February 11, 2014 10:54
Show Gist options
  • Save ejbs/8932798 to your computer and use it in GitHub Desktop.
Save ejbs/8932798 to your computer and use it in GitHub Desktop.
Small function for nice integration with git add and commit in Emacs workflow
(defun git-add-and-commit-current-file ()
(interactive)
(let ((bufn (buffer-file-name (current-buffer))))
(if bufn
(progn
(shell-command (format "git add %s" bufn))
(shell-command (format "git commit -m \"%s\"" (read-from-minibuffer "Message: "))))
(print "Current buffer has no file associated with it"))))
;; (global-set-key (kbd "C-c C-f") 'git-add-and-commit-current-file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment