summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2017-01-05 21:56:26 +0100
committerRicardo Wurmus <rekado@elephly.net>2017-01-05 21:59:17 +0100
commitd1a0ce34020744ba61d678a7052072d5300b8f38 (patch)
tree22cc7f2f3810a3a0e353130f81b1600fd8267fdf
parentcb26a2ff674d45b98d8d019f5ec7afb52761fda3 (diff)
Remove separate shell configuration file.
-rw-r--r--init.org94
-rw-r--r--lisp/init-eshell.el79
2 files changed, 93 insertions, 80 deletions
diff --git a/init.org b/init.org
index c89d55e..ed7a3d8 100644
--- a/init.org
+++ b/init.org
@@ -478,6 +478,99 @@ The default prompt face makes it hard to see the prompt.
:weight 'bold)
#+END_SRC
+I used to like Eshell a lot. Eshell is a shell implemented in Elisp. It is well integrated with the rest of Emacs. For example, you can pipe commands to buffers and use TRAMP paths right on the command line. Nowadays I’m no longer using it much because for most purposes =shell-mode= is more mature. Nevertheless, here is some configuration to make Eshell a little more usable.
+
+#+BEGIN_SRC elisp :noweb-ref eshell
+(require 'eshell)
+(setq eshell-history-size 10000)
+
+;; author: KaiGrossjohann on EmacsWiki
+(defun eshell/ff (&rest args)
+ "Invoke `find-file' on the file.
+ \"ff +42 foo\" also goes to line 42 in the buffer."
+ (while args
+ (if (string-match "\\`\\+\\([0-9]+\\)\\'" (car args))
+ (let* ((line (string-to-number (match-string 1 (pop args))))
+ (file (pop args)))
+ (find-file file)
+ (goto-line line))
+ (find-file (pop args)))))
+
+;; convenience functions to input the remote root/home dir when in a
+;; directory on a remote host
+(defun my/tramp-root ()
+ "Print root directory on the remote host."
+ (interactive)
+ (let ((pieces (split-string (eshell/pwd) ":/")))
+ (insert (if (> (length pieces) 1)
+ (concat (car pieces) ":/")
+ "/"))))
+
+(defun my/tramp-home ()
+ "Print home directory path on the remote host."
+ (interactive)
+ (let ((pieces (split-string (eshell/pwd) ":/")))
+ (insert (if (> (length pieces) 1)
+ (concat (car pieces) ":~/")
+ "~/"))))
+
+(define-key eshell-mode-map (kbd "C-c /") 'my/tramp-root)
+(define-key eshell-mode-map (kbd "C-c ~") 'my/tramp-home)
+#+END_SRC
+
+Of course, all of this should only be loaded when Eshell is used.
+
+#+BEGIN_SRC elisp
+(with-eval-after-load "eshell"
+ <<eshell>>
+)
+#+END_SRC
+
+TODO: here’s the rest of my shell configuration:
+
+#+BEGIN_SRC elisp
+(require 'shell-switcher)
+(setq shell-switcher-mode t)
+(add-hook 'eshell-mode-hook 'shell-switcher-manually-register-shell)
+(add-hook 'shell-mode-hook 'shell-switcher-manually-register-shell)
+(setq shell-switcher-new-shell-function 'shell-switcher-make-shell)
+
+;; use cat as the pager in shell mode, because shell-mode is not an
+;; ANSI terminal
+(setenv "PAGER" "cat")
+
+;; C-d on an empty line in the shell terminates the process.
+(defun my/comint-delchar-or-eof-or-kill-buffer (arg)
+ (interactive "p")
+ (if (null (get-buffer-process (current-buffer)))
+ (kill-buffer)
+ (comint-delchar-or-maybe-eof arg)))
+
+(add-hook 'shell-mode-hook
+ (lambda ()
+ ;; needed for proper display of "ls"
+ (setq tab-width 8)
+
+ ;; load shared bash history
+ (setq comint-input-ring-file-name "~/.bash_history")
+ (comint-read-input-ring t)
+
+ (define-key shell-mode-map
+ (kbd "C-d") 'my/comint-delchar-or-eof-or-kill-buffer)
+ (define-key shell-mode-map
+ (kbd "<up>") 'comint-previous-matching-input-from-input)))
+
+;; TODO: this isn't working
+(add-hook 'term-mode-hook
+ (lambda ()
+ (define-key term-mode-map
+ (kbd "C-d") 'my/comint-delchar-or-eof-or-kill-buffer)))
+
+;; Show current path instead of just "*shell*<2>"
+(setq uniquify-buffer-name-style 'forward)
+(require 'uniquify)
+#+END_SRC
+
* Magit
:PROPERTIES:
:header-args: :noweb-ref magit
@@ -1303,7 +1396,6 @@ This is even more stuff to be done after initialising packages. I still need to
(setq tab-width 4)
(setq gnus-select-method '(nntp "news.gmane.org"))
-(load "init-eshell.el")
(load "init-modeline.el")
(load "init-my-stuff.el")
diff --git a/lisp/init-eshell.el b/lisp/init-eshell.el
deleted file mode 100644
index d60356e..0000000
--- a/lisp/init-eshell.el
+++ /dev/null
@@ -1,79 +0,0 @@
-(require 'eshell)
-(require 'shell-switcher)
-(setq shell-switcher-mode t)
-(add-hook 'eshell-mode-hook 'shell-switcher-manually-register-shell)
-(add-hook 'shell-mode-hook 'shell-switcher-manually-register-shell)
-(setq shell-switcher-new-shell-function 'shell-switcher-make-shell)
-(setq eshell-history-size 10000)
-
-;; author: KaiGrossjohann on EmacsWiki
-(defun eshell/ff (&rest args)
- "Invoke `find-file' on the file.
- \"ff +42 foo\" also goes to line 42 in the buffer."
- (while args
- (if (string-match "\\`\\+\\([0-9]+\\)\\'" (car args))
- (let* ((line (string-to-number (match-string 1 (pop args))))
- (file (pop args)))
- (find-file file)
- (goto-line line))
- (find-file (pop args)))))
-
-
-;; convenience functions to input the remote root/home dir when in a
-;; directory on a remote host
-(defun my/tramp-root ()
- "Print root directory on the remote host."
- (interactive)
- (let ((pieces (split-string (eshell/pwd) ":/")))
- (insert-string (if (> (length pieces) 1)
- (concat (car pieces) ":/")
- "/"))))
-
-(defun my/tramp-home ()
- "Print home directory path on the remote host."
- (interactive)
- (let ((pieces (split-string (eshell/pwd) ":/")))
- (insert-string (if (> (length pieces) 1)
- (concat (car pieces) ":~/")
- "~/"))))
-
-;; use cat as the pager in shell mode, because shell-mode is not an
-;; ANSI terminal
-(setenv "PAGER" "cat")
-
-;; C-d on an empty line in the shell terminates the process.
-(defun my/comint-delchar-or-eof-or-kill-buffer (arg)
- (interactive "p")
- (if (null (get-buffer-process (current-buffer)))
- (kill-buffer)
- (comint-delchar-or-maybe-eof arg)))
-
-(add-hook 'shell-mode-hook
- (lambda ()
- ;; needed for proper display of "ls"
- (setq tab-width 8)
-
- ;; load shared bash history
- (setq comint-input-ring-file-name "~/.bash_history")
- (comint-read-input-ring t)
-
- (define-key shell-mode-map
- (kbd "C-d") 'my/comint-delchar-or-eof-or-kill-buffer)
- (define-key shell-mode-map
- (kbd "<up>") 'comint-previous-matching-input-from-input)))
-
-;; TODO: this isn't working
-(add-hook 'term-mode-hook
- (lambda ()
- (define-key term-mode-map
- (kbd "C-d") 'my/comint-delchar-or-eof-or-kill-buffer)))
-
-(add-hook 'eshell-mode-hook
- '(lambda ()
- (define-key eshell-mode-map (kbd "C-c /") 'my/tramp-root)
- (define-key eshell-mode-map (kbd "C-c ~") 'my/tramp-home)))
-
-;; Show current path instead of just "*shell*<2>"
-(setq uniquify-buffer-name-style 'forward)
-(require 'uniquify)
-