Skip to content

Instantly share code, notes, and snippets.

@kurohuku
Created August 8, 2013 14:16
Show Gist options
  • Save kurohuku/6184953 to your computer and use it in GitHub Desktop.
Save kurohuku/6184953 to your computer and use it in GitHub Desktop.
;;; -*- coding:utf-8 mode:emacs-lisp -*-
;;; helm-eshell-dirstack.el
(eval-when-compile (require 'cl))
(require 'helm)
(require 'eshell)
(defun helm-eshell-dirstack-popd (n)
(eshell/popd (format "+%d" n))
(eshell-begin-on-new-line)
(eshell-emit-prompt))
(defun helm-eshell-dirstack-cd (n)
(eshell/cd (nth (- n 1) eshell-dirstack))
(eshell-begin-on-new-line)
(eshell-emit-prompt))
(defvar helm-eshell-dirstack-cache nil)
(defvar helm-source-eshell-dirstack
`((name . "Eshell dirstack")
(init . (lambda ()
(setq helm-eshell-dirstack-cache
(loop for i from 1
for dir in eshell-dirstack
collect (cons dir i)))))
(candidates . helm-eshell-dirstack-cache)
(action . (("cd" . helm-eshell-dirstack-cd)
("popd" . helm-eshell-dirstack-popd)))))
(defun helm-eshell-dirstack ()
(interactive)
(helm :sources '(helm-source-eshell-dirstack)
:buffer "*helm dirstack*"))
(provide 'helm-eshell-dirstack)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment