Skip to content

Instantly share code, notes, and snippets.

@dfeich
dfeich / dfeich-hydras.el
Created May 10, 2018 15:33
Context specific Hydra launcher and some hydras used in it
;;; ** Hydras
;;; *** context launcher for hydras
(defun dfeich/context-hydra-launcher ()
"A launcher for hydras based on the current context."
(interactive)
(cl-case major-mode
('org-mode (let* ((elem (org-element-context))
(etype (car elem))
(type (org-element-property :type elem)))
(cl-case etype
@dfeich
dfeich / dfeich-ansi-terminal.el
Created March 16, 2017 20:58
Emacs function to open an ansi-term at a local or remote location
(defun dfeich/ansi-terminal (&optional path name)
"Opens an ansi terminal at PATH. If no PATH is given, it uses
the value of `default-directory'. PATH may be a tramp remote path.
The ansi-term buffer is named based on `name' "
(interactive)
(unless path (setq path default-directory))
(unless name (setq name "ansi-term"))
(ansi-term "/bin/bash" name)
(let ((path (replace-regexp-in-string "^file:" "" path))
(cd-str
@dfeich
dfeich / dfeich-gnome-term.el
Last active November 23, 2018 13:04
Emacs function to open a gnome-terminal at location of default-directory (handles remote locations)
(defun dfeich/gnome-terminal (&optional path)
"Opens a gnome terminal at PATH. If no PATH is given, it uses
the value of `default-directory'. PATH may be a tramp remote path."
(interactive)
(unless path (setq path default-directory))
(if (tramp-tramp-file-p path)
(let ((tstruct (tramp-dissect-file-name path)))
(cond
((equal (tramp-file-name-method tstruct) "ssh")
(call-process "/usr/bin/gnome-terminal" nil nil nil