File: README.org

package info (click to toggle)
eshell-up 0.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 140 kB
  • sloc: lisp: 102; makefile: 7
file content (103 lines) | stat: -rw-r--r-- 2,661 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#+STARTUP: showall

#+TITLE: eshell-up.el

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_SRC

Now, 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 fir
/home/user/first $
#+END_SRC

This command searches the current path from right to left for a
directory that matches the user's input (=fir= in this case). If a
match is found then =eshell= changes to that directory, otherwise it
does nothing.

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 fir}
<directory contents>
...
#+END_SRC

*** Adding an alias

It 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

** 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_SRC

Now, put the following in your =.emacs= file:

#+BEGIN_SRC elisp
(require 'eshell-up)
#+END_SRC

** Configuration (optional)

To make searches case sensitive add the following to your =.emacs=
file:

#+BEGIN_SRC elisp
(setq eshell-up-ignore-case nil)
#+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_SRC

Alternatively, 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.