Add some eshell configuration

This commit is contained in:
Wojciech Kozlowski 2018-02-08 06:55:21 +00:00
parent 9f27f0ffcb
commit 0608ec261d

View File

@ -26,6 +26,10 @@
(defun emodule/terminal-init ()
;; --------------------------------------------------------------------------
;; Configure term.
;; --------------------------------------------------------------------------
(use-package term
:init
(defun x-term-setup ()
@ -103,4 +107,52 @@
(global-set-key (kbd "C-x '") 'visit-ansi-term))
;; --------------------------------------------------------------------------
;; Configure eshell.
;; --------------------------------------------------------------------------
(setq eshell-visual-commands (nconc eshell-visual-commands '("htop"
"tmux")))
(defun eshell-here ()
"Opens up a new shell in the directory associated with the
current buffer's file."
(interactive)
(let* ((parent (file-name-directory (buffer-file-name)))
(name (car
(last
(split-string parent "/" t)))))
(split-window-vertically)
(other-window 1)
(eshell "new")
(rename-buffer (concat "*eshell: " name "*"))
(insert (concat "ls"))
(eshell-send-input)))
(defun delete-single-window (&optional window)
"Remove WINDOW from the display. Default is `selected-window'.
If WINDOW is the only one in its frame, then `delete-frame' too."
(interactive)
(save-current-buffer
(setq window (or window (selected-window)))
(select-window window)
(kill-buffer)
(if (one-window-p t)
(delete-frame)
(delete-window (selected-window)))))
(defun eshell/x (&rest args)
(delete-single-window))
(defun eshell-setup ()
(interactive)
(define-key eshell-mode-map (kbd "C-0") 'delete-window))
(add-hook 'eshell-mode-hook 'eshell-setup t)
(global-set-key (kbd "C-x /") 'eshell-here)
)
Marker points into wrong buffer: #<marker at 400 in *ansi-term*>
x