Dhop reimplemented in Rust 🔗

I recently spent some time updating an old friend with new language skills!

A bit of context 🔗

Dhop is a program that I wrote in around 2013 to fulfill a desire that I had to more easily manage commonly-used directories from the command-line. It allows you to save paths in a trio of ways:

  • set a filesystem-wide name for a path which you can use to refer to it later. In its simplest (and most useful) form, you can name the directory you're currently in:

    $ dhop set website
    Set location 'website' to '/home/eron/src/abstrys-web'.
    

    Then, wherever you are in the filesystem later, this returns you there:

    $ dhop website
    Moving to '/home/eron/src/abstrys-web'.
    

    You can pre-plan a journey by assigning the path explicitly:

    $ dhop set website ~/src/abstrys-web
    Set location 'website' to '/home/eron/src/abstrys-web'.
    
  • mark a path so that you can recall to it later. Yes, fellow nerds, this is a specific reference to the similarly-named magic spells in Morrowind, and it works exactly the same way:

    $ dhop mark
    Path '/home/eron/src/games/madblox/src/media' is now marked.
    

    There can only ever be one marked location. I tend to use this command to mark the place I'm currently working, making it easy to return there from anywhere:

    $ dhop recall
    Moving to '/home/eron/src/games/madblox/src/media'.
    

    A mark is permanent until a new path is marked. So recall can be used many times to keep returning to the same spot.

  • push and pop paths from a stack. While using this, you can specify either a previously-named location or just submit a directory path:

    $ dhop push website
    Added '/home/eron/src/games/madblox/src/media' to stack.
    Moving to '/home/eron/src/abstrys-web'.
    

    Later, you can use pop to return to the last-pushed directory:

    $ dhop pop
    Moving to '/home/eron/src/games/madblox/src/media'.
    

All of these places—named locations, marked locations, and the location stack—are persistent across command-line sessions.

There are also a few other commands used to provide info about these saved locations:

  • path reveals the path associated with a named location without taking you there:

    $ dhop path blog
    /home/eron/src/abstrys-web/source/blog
    

    I use this command, for example, to inject the path associated with a name without having to type it:

    $ cp -r source_files `dhop path cur-work`/source
    
  • list catalogs all of the known locations, including the marked path and the location stack:

    $ dhop list
    {
       "locations": {
          "dhop": "/home/eron/src/dhop",
          "blog": "/home/eron/src/abstrys-web/source/blog",
          "website": "/home/eron/src/abstrys-web"
       },
       "stack": [],
       "mark": "/home/eron/src/games/madblox/src/media"
    }
    

It's one of those generally-useful programs that I use wherever I'm working.

The Rust reimplementation 🔗

The original implementation of Dhop was written in Python. Both because I was learning it at the time, and also because I hate typing long pathnames and wanted a simpler way to navigate in my usual computing environment, which has been primarily the command-line (ssh much?).

Fast-forward to 2026, and although I still write code in Python (and even C/C++ for that matter), I've learned enough Rust, and also about CLI design in general, that I wanted to revisit this old workhorse and reimplement it as a static binary with some interface and functionality refinements.

Some of the changes from the old Python version include:

  • Better accessibility. Every command now provides some type of confirmation, instead of silently succeeding (or failing).

  • Removal of the cp, mv and rm commands. The implementation of these in the original Python version wasn't as good as I imagined. I tended to just pipe dhop path <name> to the actual os-level cp, mv, and rm commands.

  • dhop is much faster now!

Any future updates will target this version of dhop. The Python version still exists for reference, but I recommend using the Rust version. It's a better experience overall.

Installing Dhop 🔗

If you're a command-line citizen and think you might find it useful, have a look at the installation instructions on GitHub.

More information 🔗

See dhop on GitHub for more information, or if you're interested in poking through the source.