https://github.com/peterwvj/eshell-up
Quickly go to a specific parent directory in eshell
https://github.com/peterwvj/eshell-up
elisp emacs emacs-lisp eshell melpa
Last synced: 6 months ago
JSON representation
Quickly go to a specific parent directory in eshell
- Host: GitHub
- URL: https://github.com/peterwvj/eshell-up
- Owner: peterwvj
- License: gpl-3.0
- Created: 2016-10-14T22:05:15.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-02-26T17:48:59.000Z (over 1 year ago)
- Last Synced: 2025-03-23T20:43:27.186Z (7 months ago)
- Topics: elisp, emacs, emacs-lisp, eshell, melpa
- Language: Emacs Lisp
- Size: 41 KB
- Stars: 34
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
- License: LICENSE.md
Awesome Lists containing this project
README
#+STARTUP: showall
#+TITLE: eshell-up.el
[[https://melpa.org/#/eshell-up][file:https://melpa.org/packages/eshell-up-badge.svg]]
[[https://stable.melpa.org/#/eshell-up][file:https://stable.melpa.org/packages/eshell-up-badge.svg]]
[[https://travis-ci.org/peterwvj/eshell-up.svg?branch=master]]
[[http://www.gnu.org/licenses/gpl-3.0.html][http://img.shields.io/:license-gpl3-blue.svg?style=flat-square]]Emacs package for quickly navigating to a specific parent directory in
~eshell~ without having to repeatedly typing ~cd ..~.** Usage
Navigating to a specific parent directory is achieved using the
~eshell-up~ function, which can be bound to an ~eshell~ alias such as
~up~.*** Examples
To demonstrate how to use ~eshell-up~ let's assume that the current
working directory of ~eshell~ is:#+BEGIN_SRC bash
/home/user/first/second/third/fourth/fifth $
#+END_SRCNow, in order to quicky go to (say) the directory named ~first~ one
simply executes:#+BEGIN_SRC bash
/home/user/first/second/third/fourth/fifth $ up fi
/home/user/first $
#+END_SRCThis command searches the current path from right to left (while
skipping the current directory, ~fifth~) for a directory that matches
the user's input (~fi~ in this case). If a match is found then
~eshell~ changes to that directory, otherwise it does nothing. If, on
the other hand, no argument is passed to ~eshell-up~, this command
simply changes to the nearest parent directory (like ~cd ..~ does).It is also possible to compute the matching parent directory without
changing to it. This is achieved using the ~eshell-up-peek~ function,
which can be bound to an alias such as ~pk~. When this function is
used in combination with /subshells/ the matching parent directory can
be passed as an argument to other functions. Returning to the
previous example one can (for example) list the contents of ~first~ by
executing:#+BEGIN_SRC bash
/home/user/first/second/third/fourth/fifth $ ls {pk fi}...
#+END_SRC** Installation
~eshell-up~ is available via [[https://github.com/melpa/melpa][MELPA]]. To add it to Emacs execute the
following:#+BEGIN_SRC elisp
package-install RET eshell-up RET
#+END_SRCNow, put the following in your ~.emacs~ file:
#+BEGIN_SRC elisp
(require 'eshell-up)
#+END_SRCIt is recommended to invoke ~eshell-up~ and ~eshell-up-peek~ using
aliases as done in the examples above. To do that, add the following
to your ~.eshell.aliases~ file:#+BEGIN_SRC
alias up eshell-up $1
alias pk eshell-up-peek $1
#+END_SRC** Configuration (optional)
To make ~eshell-up~ searches case sensitive:
#+BEGIN_SRC elisp
(setq eshell-up-ignore-case nil)
#+END_SRCTo print the matching parent directory before changing to it:
#+BEGIN_SRC elisp
(setq eshell-up-print-parent-dir t)
#+END_SRC** Testing
The test are written using [[https://www.gnu.org/software/emacs/manual/ert.html][ERT]], and can be executed as follows:
#+BEGIN_SRC elisp
load-file eshell-up-tests.el
ert t
#+END_SRCAlternatively, the tests can be run in batch mode:
#+BEGIN_SRC bash
emacs -Q --batch -L . -l ert -l eshell-up-tests.el -f ert-run-tests-batch-and-exit
#+END_SRC** Credits
This package is inspired by [[https://github.com/vigneshwaranr/bd][bd]], which uses bash to implement similar
functionality.