Skip to content

Instantly share code, notes, and snippets.

@satyr
Created November 2, 2008 01:40
Show Gist options
  • Save satyr/21615 to your computer and use it in GitHub Desktop.
Save satyr/21615 to your computer and use it in GitHub Desktop.
(defun run-console () (interactive)
(launch-application
"cmd /k clear&&title cmd&&prompt $P$S[$D$S$T]$S$M$_$+$G$S"))
(defvar *last-command-cmd* "")
(defun command-cmd (cmd) (interactive "e> " :history0 'execute)
(execute-shell-command
(substitute-string (setq *last-command-cmd* cmd)
"\\?\\?" (or (get-buffer-file-name)
(buffer-name (selected-buffer))))
nil "*cmd*")
(other-window))
(defun repeat-command-cmd () (interactive)
(command-cmd *last-command-cmd*))
(set-extended-key-translate-table exkey-C-space #\C-F20)
(global-set-key #\C-F20 'command-cmd)
(global-set-key '(#\C-x #\SPC) 'repeat-command-cmd)
(defvar *last-command-sh* "")
(defun command-sh (sh) (interactive "e$ " :history0 'execute)
(execute-shell-command
(concat
"sh -c \""
(substitute-string
(substitute-string (setq *last-command-sh* sh)
"\"" "\"\"\"")
"\\?\\?" (or (get-buffer-file-name)
(buffer-name (selected-buffer))))
"\"")
nil "*sh*")
(other-window))
(defun repeat-command-sh () (interactive)
(command-sh *last-command-sh*))
(set-extended-key-translate-table exkey-S-C-space #\S-C-F20)
(global-set-key #\S-C-F20 'command-sh)
(global-set-key '(#\C-x #\S-C-F20) 'repeat-command-sh)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment