Giter Club home page Giter Club logo

gitree's Introduction

@jpwilliams/gitree

Print a directory tree that shows Git status and ignores files dictated by .gitignore.

$ npm i -g @jpwilliams/gitree
$ gitree

# OR

$ npx @jpwilliams/gitree

What?

gitree works very similarly to tree but only lists files related to the current git repository.

Like Git, gitree only tracks files, so empty directories will never be listed. If you wish to push an empty folder to a Git repository, add an empty .gitignore or .gitkeep file to the directory and commit it.

What does it show?

gitree shows any files that your repository's .gitignore files allows you to see, marking them with useful statuses like the ones in the screenshot above.

What if it's not a Git repository?

It won't work. You must be somewhere within a Git repository to list any files. If you just want a basic tree view without Git integration, consider the built-in tree command for Linux/Windows or the tree homebrew formula for Mac OSX.

What else can it do?

Just this stuff:

Usage: gitree [options] [dir]


Options:

  -V, --version           output the version number
  -m, --modified          only show modified files
  -t, --tracked           only show tracked files
  -c, --collapse          collapse directory nodes that contain a single child
  -d, --devicons          print matching devicons next to files
  -I, --ignore <pattern>  do not list files that match the given pattern
  -h, --help              output usage information

Note that for devicons to work, you must have a font with devicon glyphs installed. A good place to start is Nerd Fonts.

Can it get any cooler?

There's a built-in alias, gt. Fantabulous, eh?

Alternatives

The wonderful ogham/exa can print a similar tree without detailed change information/filtering with:

exa --git-ignore --tree --all --icons --ignore-glob .git

gitree's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar jpwilliams avatar renovate[bot] avatar scottbilas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gitree's Issues

Do colours for directories work on MacOS?

Hi I love this, was just wondering if it's meant to show colours for directories and such? Mine just come out grey, but your picture looks like they're blue and bold? Modified ones do go yellow so I'm not sure what's up

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Cannot find preset's package (github>whitesource/merge-confidence:beta)

Filter additional given directories as inputs

I love this script, thank you.

I often have a directory containing stuff I need, but usually not super important when looking what's up, how could quickly filter those.

gt --filter a b c

Would be absolutely amazing and useful.

PS: Oh..., I'm #13. Like #13 is every solved.

Hidden files are not listed

We could do this whole thing better using only Git.

Grab a list of all commited/changed/w/e files:

git ls-files --exclude-standard --directory --no-empty-directory -s | awk -F"\t" '{print $2}'

Switch that list option out for -o and drop the awk to list all untracked files.

That way we get everything directly related to Git and can still build a tree as we have the full paths.

Feature request: Group by type

Hello,

First of all, gitree is a pretty neat tool!

##I have a feature request.
It could be nice to group folders together and then files in the output.

Lets have an exemple:

└── api
    ├── assets
    │   └── img
    ├── index.js
    ├── package-lock.json
    ├── package.json
    └── twig
        ├── _layouts
        │   └── default.twig
        ├── index.twig
        └── partials
            ├── header.twig
            └── socials.twig

What if folders were at the top ?

└── api
    ├── assets
    │   └── img
    └── twig
    │   ├── _layouts
    │   │   └── default.twig
    │   └── partials
    │   │   ├── header.twig
    │   │   └── socials.twig
    │   └── index.twig
    ├── index.js
    ├── package-lock.json
    └── package.json

Does it make sense ?
Am I the only one looking for this kind of output ?

Providing an absolute path produces odd directory results

👉  ~/remit - master 👋  gitree /Users/jpwilliams/remit
Users/jpwilliams/remit
└── ..
    └── ..
        └── ..
            ├── .coveralls.yml
            ├── .eslintrc
            ├── .gitignore
            ├── .travis.yml
            ├── index.js

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Warning

These dependencies are deprecated:

Datasource Name Replacement PR?
npm eslint-plugin-node Available
npm eslint-plugin-standard Unavailable

Pending Approval

These branches will be created by Renovate only once you click their checkbox below.

  • Replace dependency eslint-plugin-node with eslint-plugin-n 14.0.0
  • Update actions/checkout action to v4
  • Update actions/setup-node action to v4
  • Update dependency chalk to v5
  • Update dependency commander to v12
  • Update dependency eslint to v9
  • Update dependency eslint-plugin-promise to v7
  • Update dependency execa to v9
  • Update dependency ignore to v6
  • 🔐 Create all pending approval PRs at once 🔐

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/npmpublish.yml
  • actions/checkout v2
  • actions/setup-node v2
  • actions/checkout v2
  • actions/setup-node v2
  • actions/checkout v2
  • actions/setup-node v2
npm
package.json
  • chalk ^4.0.0
  • commander ^4.1.1
  • execa ^5.0.0
  • ignore ^5.1.4
  • microloader ^0.4.2
  • parse-git-status ^0.1.0
  • eslint 7.21.0
  • eslint-plugin-import 2.22.1
  • eslint-plugin-node 11.1.0
  • eslint-plugin-promise 4.3.1
  • eslint-plugin-standard 5.0.0

  • Check this box to trigger a request for Renovate to run again on this repository

`-l` option to show permissions and size

In the spirit of ls -l

The main file attributes of concern for git that are not visible in gitree currently are file size and permissions.

An alternative might be to colour executable files differently, in the same way, since this is the main permission that matters.

It would also be nice to have a -c flag to show the most recent commit that a file was changed in, with some date and author information.

Since reformat, -m flag no longer works

The -m flag does nothing now.

It's passed to the looper utility, but it doesn't make use of it.

The idea was that we'd use it to stop files logging from there, but the best we can do without a larger change is to log all folders and changed files. That's because stuff gets logged as it comes in, so the folders don't know they're empty as they'll never be listed in git ls-files. Joy, eh?

Will figure this out some point soon. The slight reformat is for the best, just need a happy way to sort this out.

Files listed inside a directory do not show statuses

Files listed inside a directory are returned relatively to the current directory whilst the statuses are given as relative to the Git root directory.

This mismatch means that running gitree inside a directory within a Git repository shows no (or possibly incorrect) status information.

We'll need to somehow parse everything as relative to the Git root when we figure out statuses etc, but then clip parts of the path before we build a tree.

fix: File name display error

image

>node -v
v14.15.5

>gitree -V
1.5.1

>gitree
.
├── "client
│   └── 2QQ
│       └── 345
│           └── 233
│               └── 276
│                   └── 347
│                       └── 211
│                           └── 20720230107114205.png"
├── .gitignore
├── client
│   ├── 2QQ图片20230107114205.png (untracked)
│   ├── index.js
│   ├── package.json +5 -1
│   ├── readme.md
│   ├── t.js (untracked)
│   ├── util.js
│   └── yarn.lock +322
├── gulpfile.js
├── package.json
├── readme.md +1
├── server
│   ├── .gitignore
│   ├── index.js
│   ├── package.json
│   ├── util.js
│   └── yarn.lock +54 -145
└── yarn.lock

Ability to set default options

It would be nice to be able set the default options.

For now I've created a git alias

zsh:

git config --global alias.tree "\!gitree -m -c"

./git/config file:

[alias]
	tree = "!gitree -m -c"

Usage:

image

Depth limiting

tree has the -L option that allows depth limiting of the tree. This would be super useful in gitree too. Happy to make a PR if it would be appreciated.

Staged deleted files are not shown

git ls-files doesn't show staged deleted files.

git status --porcelain -z -uall still lists it, however. Is there a nice way we can leverage that to still include it in the listings?

This change may go hand-in-hand with reformatting the statuses so that we assign x, y, from and to to all files before we start looping over them to log 'em.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.