Skip to content

JosephLai241/nomad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

   ________  ________  ________  ________   _______ 
  β•±    β•±   β•²β•±        β•²β•±        β•²β•±        β•²_β•±       β•²
 β•±         β•±         β•±         β•±         β•±         β•±
β•±         β•±         β•±         β•±         β•±         β•± 
β•²__β•±_____β•±β•²________β•±β•²__β•±__β•±__β•±β•²___β•±____β•±β•²________β•±  

The customizable next gen tree command with Git integration and TUI.

Rust GitHub Workflow Status GitHub release (latest by date) Lines of code License

Table of Contents

Introduction

nomad is a rewrite of the tree command with a ton of additional features such as Git integration, built-in bat and tokei, the ability to customize its appearance, and even a TUI (terminal UI) mode.

I think the tree command is a useful CLI tool, but is unfortunately lacking some features that I think would make it even better. I decided to build my own next gen tree command that implements the features I would have wanted in the original tree command.

"This README barely explains what nomad does. Where the hell is the manual?"

The manual for nomad was originally this README, but it became too long to comfortably navigate. This README merely serves as a preview of sorts with some information for each feature whereas the manual provides a more in-depth look at nomad.

The manual is available here and is also linked in the About section of this repository.

Prerequisites

nomad's icons require a NerdFont to render correctly. Refer to the NerdFont installation instructions to install a NerdFont for your system. It is quite simple to do and will not take too long.

Standard Usage

standard-demo

By default, nomad will display a tree visual representing the directory structure of the target directory and respect rules specified in ignore-type files such as .gitignores. This behavior may be disabled.

Each item will also be labeled with a NerdFont-supported icon corresponding to its filetype as well as Git status markers indicating the Git status of the file. See the Git Status Markers section to learn more about what each default marker/color represents.

Unlocked Functionality via Item Labels

nomad's capabilities are drastically enhanced through the use of item labels.

These are the flags that will apply labels to items within the tree:

Flag Function
-l Applies labels to directories only
-n Applies labels to items only
-L Applies labels to directories and items. An alias for -l -n

bat - bat Files in the Tree

bat demo

NOTE: Requires a preceeding run in a labeled mode.

Quickly bat files by passing item labels into the bat subcommand.

NOTE: This command works with item and/or directory labels. If directory labels are provided, all items within that directory will be bated in the order they appear.

edit - Edit Files in the Tree

edit demo

Opened with Neovim, the best text editor.

NOTE: Requires a preceeding run in a labeled mode.

Quickly edit files by passing item labels into the edit subcommand.

nomad will attempt to open files with your $EDITOR if it is set. If not, it will try the following text editors in this order:

  1. Neovim
  2. Vim
  3. Vi
  4. Nano

NOTE: This command works with item and/or directory labels. If directory labels are provided, all items within that directory will be opened in a text editor.

tokei

Tokei may be accessed through the subcommand or in tree view to display LoC data for individual files.

tokei - Subcommand (Overview)

tokei subcommand demo

You can quickly see a tokei summary/overview for a project by using the tokei subcommand.

nd --tokei - Flag (Tree View)

tokei tree demo

You can view tokei statistics for individual files by using the --tokei flag. This will display the lines of blanks, code, comments, and total number of lines for each file.

Filtering (Including or Excluding) Items by Filetype

You can filter out items in a directory by matching or negateing filetypes or globs.

ft match - Including Filetypes and/or Globs

filetype match demo

ft negate - Excluding Filetypes and/or Globs

filetype negate demo

ft options - Viewing Filetype Globs

filetype options demo

You can view all the preset globs for each filetype by using the ft options subcommand. Optionally specify a filetype after the subcommand to search/view the globs for that specific filetype.

Git Integration

nomad has Git integration to allow for easy access to commonly used Git subcommands!

Git Status Markers

Here is a table that contains the default Git status markers, the marker's color, and what it represents:

Marker Color Status
! Red Conflicting
D Red Deleted
M Orange Modified
R Orange Renamed
TC Purple Type change
SA *Green Staged, Added
SD *Red Staged, Deleted
SM *Orange Staged, Modified
SR *Orange Staged, Renamed
STC *Purple Staged, type change
U Gray Untracked

* The filename will also be painted the same color.

NOTE: Staged deleted filenames will also be painted with a strikethrough.

If you do not like the default marker or color configuration, you can customize it to your liking.

git add

🚧 This feature is currently in beta 🚧

git add demo

NOTE: Requires a preceeding run in a labeled mode.

Quickly git add files by passing items labels into the subcommand.

NOTE: This command works with item and/or directory labels. If directory labels are provided, all items within that directory that are tracked by Git and contain a Git status will be added.

git blame

git blame demo

NOTE: Requires a preceeding run in a labeled mode.

Quickly run git blame on a file by passing an item label into the subcommand.

NOTE: This command only accepts one item label.

Commits made by you remain plain while commits made by other authors are painted with a color. Each author is assigned a random color, so these colors will be different each time you run git blame.

Be sure to check out Mojibar, a cross-platform, quick-access tab and search bar for emojis written by my friend Luke Schenk.

git branch

git branch demo

You can view git branch in tree form. This works especially well if your branch names look like filepaths. Some examples are:

  • feature/git/something-new
  • bugfix/some-bug

git commit

🚧 This feature is currently in beta 🚧

git commit demo

git commit has been integrated for convenience and offers some visual improvements over the original command.

git diff

git diff demo

NOTE: Requires a preceeding run in a labeled mode.

Quickly git diff files by passing item labels into the subcommand. This command offers visual improvements and additional data over the original command.

NOTE: This command works with item and/or directory labels. If directory labels are provided, all items within that directory that are tracked by Git and contain a Git status will be diffed in the order they appear.

git status

git status demo

You can view git status in tree form. This command will only display items that are tracked by Git and contain changes or are untracked.

Rootless Mode

rootless mode demo

Rootless mode is the TUI (terminal UI) mode that allows you to dynamically interact with directory trees.

There are three primary widgets that you can interact with. Here is a quick description of each widget:

Widget Description Location
Breadcrumbs Contains path breadcrumbs for parent directory navigation Top
Inspect Contains the contents of the selected item Right
Normal Contains the directory tree Left

Configuration/Customization

You can configure/customize nomad without the hassles of creating your own configuration file in the correct directory with the correct syntax.

"What Can I Customize?"

Here is a list of what you can customize for standard mode:

  • The tree's indentation and padding
  • The directory's color
  • The tree's indent characters (|, β”œ, ─, β””)
  • The directory and item label's color
  • Git status markers and colors
  • The color of the pattern/regex match (when using the -p/--pattern flag)

Here is a list of what you can customize for Rootless mode:

  • The color of the widget borders
  • The color of a standard item in the tree (one that does not contain any Git changes)
  • The color of items that contain a Git status
  • The color of the pattern/regex match when searching for patterns within the tree or file

The following standard mode settings will also be applied to the Normal widget within Rootless mode:

  • Indentation/padding
  • Intent characters
  • Git markers

config edit - Editing the Configuration File

config edit demo

You can easily access the configuration file by using the config edit subcommand.

config preview - Previewing Your Configurations

config preview demo

You can preview all your configuration options in a dummy tree by using the config preview subcommand.

Inspirations

Be sure to check out the tools that inspired me to create this project!

  • tree - the OG command
  • lsd - a modern ls alternative/rewrite