Skip to content
Avindra Goolcharan edited this page Jun 9, 2021 · 8 revisions

Profile setup

To use dirp, you need to hook in your shell profile. This is also the only time users should ever directly reference the dirp binary.

Here are usage patterns for different shells:

  • Traditional shells: eval "$(dirp hook)"
    • Compatible: ✅ Bash, BusyBox, ZSH, Dash
  • Fish shell: dirp hook fish | source
    • Compatible: ✅ fish >= 3.1.2
  • Plan 9†† shells
    • Compatible: ✅ rc eval `{dirp hook rc}
    • Compatible: ✅ es eval `{dirp hook es}

ZSH compatibility

ZSH is compatible, but only if existing dir aliases are removed. To do this, write unalias dir before adding the hook. The full install for ZSH looks like:

unalias dir &> /dev/null
eval "$(dirp hook)"

Otherwise, ZSH (as of 5.8) will just throw this rather unhelpful error message:

(eval):7: defining function based on alias `dir'
(eval):7: parse error near `()'

Unfortunately, when the hook is evaluated by ZSH, the ZSH parser bails out early, so our internal unalias call doesn't get a chance to run.

A simple workaround for this is to require users to place the unalias call before the eval. This avoids the need to create a special ZSH hook.

†† Plan 9 support

Support for rc, the Plan 9 shell was implemented using the Rakitzis port. Compatibility with an actual Plan 9 system is not known, especially since 9 does not have find, which is used in the driller feature.

Implementation details

In some pre-configured shells, you might find an existing dir alias to ls as a convenience for DOS users. The hook will detect such entries and replace them with the entrypoints for dirp instead. ZSH users will have to do this manually (see note above).