Skip to main content

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 cd usage 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)

Source distribution for xontrib-hist-navigator 1.0.1
File Size Uploaded
xontrib-hist-navigator-1.0.1.tar.gz 4.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xontrib-hist-navigator 1.0.1
File Interpreter ABI Platform
xontrib_hist_navigator-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 8.8 kB

Release files / xontrib-hist-navigator-1.0.1.tar.gz

Download URL xontrib-hist-navigator-1.0.1.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d2f7e3c3fcb30e31e2a33d5dd015327955da183b3aa813ca0d5427cb5f1f5917
BLAKE2b-256 checksum
How to use checksums
faebd7dcbfe66f8b040a77a8010682d53093d06be0f2c55f76221b3f5f823275
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 10, 2025.

Transparency log

Release files / xontrib_hist_navigator-1.0.1-py3-none-any.whl

Download URL xontrib_hist_navigator-1.0.1-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aa7f00c4958caa4bd7de5847fa970ae76d2c2b75f642903be9de1ac4b00838e9
BLAKE2b-256 checksum
How to use checksums
928c56f66d987f232531b0cb2881875b94eaac01dfb808337ceac0884ac1ba69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 10, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

0.6.5

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page