Skip to content

Instantly share code, notes, and snippets.

@GeorgeJahad
Created July 28, 2009 02:20
Show Gist options
  • Save GeorgeJahad/156879 to your computer and use it in GitHub Desktop.
Save GeorgeJahad/156879 to your computer and use it in GitHub Desktop.
(defun gbj-backup-shell (&optional arg)
"makes a copy of the current shell with timestamp appended to the filename"
(interactive)
(let*
(
(save-dir "~/build/shells/")
(orig-file arg)
(mod-str nil)
)
(if (not orig-file)
(setq orig-file (concat save-dir (buffer-name))))
(with-temp-buffer
; get the time stamp
(insert (current-time-string))
;fix up the bad chars
(goto-char (point-min))
(while (re-search-forward "[ :]" nil t)
(replace-match "-" nil nil))
(goto-char (point-min))
(while (re-search-forward "--" nil t)
(replace-match "-" nil nil))
(setq mod-str (buffer-string)))
; copy out the file
(write-file (concat orig-file "." (substring mod-str 4 )))
(rename-buffer (file-name-nondirectory orig-file))
(setq buffer-file-name nil)
(auto-save-mode -1)
(message (format "Wrote out %s" (concat orig-file "." (substring mod-str 4 ))))
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment