├── README.md └── eshell-bookmark.el /README.md: -------------------------------------------------------------------------------- 1 | # eshell-bookmark 2 | 3 | Simple package integrating eshell with bookmark.el. 4 | 5 | Read the [blog post](https://fuco1.github.io/2017-10-08-Using-bookmarks-with-eshell-and-docker-tramp.html) for introduction. 6 | 7 | # Installation 8 | 9 | Get it from MELPA or MELPA Stable with `M-x package-install eshell-bookmark`. 10 | 11 | # Usage 12 | 13 | Enable the bookmark by adding this setup to your config: 14 | 15 | ``` emacs-lisp 16 | (add-hook 'eshell-mode-hook 'eshell-bookmark-setup) 17 | ``` 18 | 19 | Or you can also manually call `(eshell-bookmark-setup)` from any other setup hook you already have. 20 | 21 | If you use `use-package`, the setup can look something like the following: 22 | 23 | ``` emacs-lisp 24 | (use-package eshell-bookmark 25 | :after eshell 26 | :config 27 | (add-hook 'eshell-mode-hook #'eshell-bookmark-setup)) 28 | ``` 29 | 30 | After this, use the bookmark features as usual: 31 | 32 | * capture a bookmark to eshell with `C-x r m` 33 | * restore an eshell with `C-x r l` 34 | 35 | Works with remote/TRAMP hosts as well, which is super cool. 36 | -------------------------------------------------------------------------------- /eshell-bookmark.el: -------------------------------------------------------------------------------- 1 | ;;; eshell-bookmark.el --- Integrate bookmarks with eshell. -*- lexical-binding: t -*- 2 | 3 | ;; Copyright (C) 2017 Matúš Goljer 4 | 5 | ;; Author: Matúš Goljer 6 | ;; Maintainer: Matúš Goljer 7 | ;; Version: 2.0.0 8 | ;; Created: 6th September 2017 9 | ;; Package-requires: ((emacs "24.3")) 10 | ;; Keywords: convenience, files 11 | ;; URL: https://github.com/Fuco1/eshell-bookmark 12 | 13 | ;; This program is free software; you can redistribute it and/or 14 | ;; modify it under the terms of the GNU General Public License 15 | ;; as published by the Free Software Foundation; either version 3 16 | ;; of the License, or (at your option) any later version. 17 | 18 | ;; This program is distributed in the hope that it will be useful, 19 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | ;; GNU General Public License for more details. 22 | 23 | ;; You should have received a copy of the GNU General Public License 24 | ;; along with this program. If not, see . 25 | 26 | ;;; Commentary: 27 | 28 | ;; This package provides bookmark.el integration for eshell. It is 29 | ;; especially useful for quickly jumping to remote/TRAMP hosts. 30 | 31 | ;; To enable, add (add-hook 'eshell-mode-hook 'eshell-bookmark-setup) 32 | ;; to your configuration. 33 | 34 | ;;; Code: 35 | 36 | (require 'bookmark) 37 | (require 'eshell) 38 | 39 | (defun eshell-bookmark--make-record () 40 | "Create a eshell bookmark. 41 | 42 | The bookmark will try to open an eshell session with the pwd set 43 | to the location when the bookmark was created." 44 | (let ((bookmark `((handler . eshell-bookmark--restore) 45 | (filename . ,default-directory)))) 46 | bookmark)) 47 | 48 | (defun eshell-bookmark--restore (bookmark) 49 | "Restore eshell buffer according to BOOKMARK." 50 | (let ((eshell-buffer-name 51 | (or (bound-and-true-p shell-pop-last-shell-buffer-name) 52 | eshell-buffer-name))) 53 | (eshell) 54 | (setq default-directory (cdr (assq 'filename bookmark))) 55 | (eshell-reset))) 56 | 57 | ;;;###autoload 58 | (defun eshell-bookmark-setup () 59 | "Setup eshell-bookmark." 60 | (setq-local bookmark-make-record-function 'eshell-bookmark--make-record)) 61 | 62 | (provide 'eshell-bookmark) 63 | ;;; eshell-bookmark.el ends here 64 | --------------------------------------------------------------------------------