hview

hop view — a smarter ls and cat command for your terminal. It remembers which directories and files you use most frequently (accessed thru the cat or ls command), so you can list or cat them in just a few keystrokes.

← Back to portfolio

Installation

The recommended way to install hview is via the install script:

curl -sSfL https://raw.githubusercontent.com/execRooted/hview/master/install.sh | sh

If that fails and you have Rust installed:

cargo install hview --locked

Setup

After installing, add hview to your shell configuration:

Bash

Add this to the end of ~/.bashrc:

eval "$(hview init bash)"
Zsh

Add this to the end of ~/.zshrc:

eval "$(hview init zsh)"
Fish

Add this to the end of ~/.config/fish/config.fish:

hview init fish | source
PowerShell

Add this to your PowerShell profile:

Invoke-Expression (& { (hview init powershell | Out-String) })
Any POSIX shell
eval "$(hview init posix --hook prompt)"

Usage

h foo              # list the highest ranked directory matching foo
h ~/foo            # h also works like a regular ls command
h foo/             # list relative path
h ..               # list one level up

h /path/to/file    # cat a file, or ls a directory

hi                 # interactive selection (using fzf)

h foo<SPACE><TAB>  # show interactive completions

Files

hview can also remember and open files. When you run h on a file path, it will cat the file instead of lsing it. Files are added to the database automatically when you open them.

h install.sh       # cat the file install.sh
h config.yaml   # explicitly cat the file config.yaml

No matches

If no matching file or directory is found, hview will print an error message:

hview: no file/directory found

Configuration

hview can be configured using environment variables:

VariableDescription
_HVIEW_DATA_DIRDirectory for the database
_HVIEW_ECHOPrint the matched directory before listing it (1 to enable)
_HVIEW_EXCLUDE_DIRSExclude directories from the database
_HVIEW_FZF_OPTSCustom options for fzf
_HVIEW_MAXAGEMaximum age for database entries
_HVIEW_RESOLVE_SYMLINKSResolve symlinks before adding to database

fzf

For interactive selection (hi and completions), install fzf.

Import

If you're coming from another directory-jumping tool, import your data:

hview import z        # from z
hview import z.lua    # from z.lua
hview import autojump # from autojump
hview import fasd     # from fasd