Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. (defun shell-command-on-region-or-line ()
  2. "Run selected text in a terminal or use the current line."
  3. (interactive)
  4. (shell-command
  5. (concat
  6. "gnome-terminal -e "
  7. (if (use-region-p)
  8. ;; current selection
  9. (buffer-substring (region-beginning) (region-end))
  10. ;; current line
  11. (thing-at-point 'line t)))))
  12.  
  13. ;; Execute text in a terminal, no questions! (ctrl-alt-shift-enter to avoid accidents!)
  14. (global-set-key (kbd "<c-m-s-return>") 'term-shell-command-on-region-or-line)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement