Skip to main content

A Xonsh plugin to navigate between directories like fish's prevd/nextd

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xontrib-hist-navigator-1.0.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xontrib_hist_navigator-1.0.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file xontrib-hist-navigator-1.0.1.tar.gz.

File metadata

  • Download URL: xontrib-hist-navigator-1.0.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for xontrib-hist-navigator-1.0.1.tar.gz
Algorithm Hash digest
SHA256 d2f7e3c3fcb30e31e2a33d5dd015327955da183b3aa813ca0d5427cb5f1f5917
MD5 ef110d8fb77d4b78677b28ae16b712ba
BLAKE2b-256 faebd7dcbfe66f8b040a77a8010682d53093d06be0f2c55f76221b3f5f823275

See more details on using hashes here.

Provenance

The following attestation bundles were made for xontrib-hist-navigator-1.0.1.tar.gz:

Publisher: release.yml on jnoortheen/xontrib-hist-navigator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xontrib_hist_navigator-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for xontrib_hist_navigator-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 aa7f00c4958caa4bd7de5847fa970ae76d2c2b75f642903be9de1ac4b00838e9
MD5 7cb8debd20d709a8ab37131d9a9098e1
BLAKE2b-256 928c56f66d987f232531b0cb2881875b94eaac01dfb808337ceac0884ac1ba69

See more details on using hashes here.

Provenance

The following attestation bundles were made for xontrib_hist_navigator-1.0.1-py3-none-any.whl:

Publisher: release.yml on jnoortheen/xontrib-hist-navigator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page