xontrib-hist-navigator
Fish-shell like prevd and nextd for xonsh with keyboard shortcuts
Usage
- install using pip
pip install xontrib-hist-navigator
- or xpip (that is installed alongside xonsh)
xpip install xontrib-hist-navigator
- add to list of xontribs loaded.
xontrib load hist_navigator
Overview
- it keeps track of
cdusage per session - Shortcuts
| command | description | shortcut |
|---|---|---|
| prevd | move to previous working directory | Alt + Left Arrow |
| nextd | move to next working directory in the history (if prevd is used) |
Alt + Right Arrow |
| listd | list cd history | |
| cd .. | move to parent directory | Alt + Up Arrow |
Traversal behavior
By default, all cd history is kept. Let's look at an example. Let's open a new shell:
❯
Now when we change the directory, it's added to the history along with the previous directory where we were (the user's home directory):
❯ cd BASE
❯ listd
['~', '~/BASE']
Let's descend further down:
❯ cd sub
❯ listd
['~', '~/BASE', '~/BASE/sub']
So far, so obvious. Now, when we use prevd, you'll see that the history
stays intact:
❯ prevd
❯ pwd
~/BASE
❯ listd
['~', '~/BASE', '~/BASE/sub']
This allows you to use nextd to go back and forth:
❯ nextd
❯ pwd
~/BASE/sub
❯ listd
['~', '~/BASE', '~/BASE/sub']
❯ prevd
❯ pwd
~/BASE
❯ listd
['~', '~/BASE', '~/BASE/sub']
Now, if you change the directory entirely after a prevd, the entire
previous history is still kept:
❯ pwd
~/BASE
❯ listd
['~', '~/BASE', '~/BASE/sub']
❯ cd /tmp
❯ listd
['~', '~/BASE', '~/BASE/sub', '/tmp']
This means that issuing prevd now will actually return to ~/BASE/sub
and not to ~/BASE which was the last seen previous directory.
This is by design to allow you to quickly traverse previously visited
directories using keyboard shortcuts.
If you would rather have the history truncated, so that prevd always
takes you to the directory you were in just before, set the following
environment variable in your xonshrc:
$XONTRIB_HIST_NAVIGATOR_TRUNCATE="true"
In this case the last example would behave differently:
❯ pwd
~/BASE
❯ listd
['~', '~/BASE', '~/BASE/sub']
❯ cd /tmp
❯ listd
['~', '~/BASE', '/tmp']
As you can see ~/BASE/sub was dropped from history because it wasn't
the last visited directory at the time of changing the directory to
/tmp.
Release
semantic-release version && semantic-release publish
Metadata
Release files for xontrib-hist-navigator 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xontrib-hist-navigator-1.0.1.tar.gz | 4.2 kB | With provenance | Details for xontrib-hist-navigator-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xontrib_hist_navigator-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for xontrib_hist_navigator-1.0.1-py3-none-any.whl |
Total release size: 8.8 kB
Security for xontrib-hist-navigator 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.