{"id":13405800,"url":"https://github.com/dduan/tre","last_synced_at":"2025-05-15T08:02:36.557Z","repository":{"id":37276344,"uuid":"169966359","full_name":"dduan/tre","owner":"dduan","description":"Tree command, improved.","archived":false,"fork":false,"pushed_at":"2024-09-03T20:56:21.000Z","size":4214,"stargazers_count":988,"open_issues_count":18,"forks_count":21,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-04-11T19:55:13.450Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dduan.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-10T10:29:53.000Z","updated_at":"2025-04-11T07:40:20.000Z","dependencies_parsed_at":"2024-01-23T16:11:16.703Z","dependency_job_id":"6e85a233-2f32-48ad-83bd-a1715d7b6764","html_url":"https://github.com/dduan/tre","commit_stats":{"total_commits":187,"total_committers":4,"mean_commits":46.75,"dds":"0.016042780748663055","last_synced_commit":"a813038b1c0e52cbc6ce44a28bc828476f161585"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dduan%2Ftre","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dduan%2Ftre/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dduan%2Ftre/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dduan%2Ftre/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dduan","download_url":"https://codeload.github.com/dduan/tre/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254301420,"owners_count":22047901,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T19:02:12.096Z","updated_at":"2025-05-15T08:02:36.436Z","avatar_url":"https://github.com/dduan.png","language":"Rust","funding_links":[],"categories":["Rust","Files and Directories","Tools","Tools and Plugins","\u003ca name=\"file-explorer\"\u003e\u003c/a\u003eFile explorer and tree visualization","File Listing"],"sub_categories":["Directory Listing","Rust","Windows"],"readme":"# tre\n\nA modern alternative to the `tree` command that:\n\n* lists directory structure in a tree-like diagram, like the classics.\n* skips ignored files in git repositories per `.gitignore` setting.\n* creates shell aliases for each listing that opens the files for you.\n* output in colors, respecting [LS_COLORS][] settings when they exist.\n\nCommand aliasing demo:\n\n![Aliasing In Action](alias_demo.gif)\n\n… in case you missed it: `[8]` is shown in front of \"README.md\" and typing `e8`\nopened the file! See [how to set this up](#editor-aliasing).\n\n[LS_COLORS]: https://man7.org/linux/man-pages/man5/dir_colors.5.html\n\n## Install\n\n#### Via a package manager\n\nTre is available in the following package managers.\n\n| Manager / OS            | Command                      |\n| ----------------------- | ---------------------------- |\n| Homebrew / macOS        | `brew install tre-command`   |\n| MacPorts / macOS        | `port install tre-tree`      |\n| Debian (testing)        | `apt install tre-command`    |\n| Scoop / Windows         | `scoop install tre-command`  |\n| Windows Package Manager | `winget install tre-command` |\n| Cargo                   | `cargo install tre-command`  |\n| AUR / Arch Linux        | `yay -S tre-command`         |\n| pkgsrc / NetBSD 9.1+    | `pkgin install tre-command`  |\n| Nixpkgs / NixOS         | Use `tre-command`            |\n| Nix flake               | Use `github:dduan/tre`       |\n\n_The commands above are basic instructions. Use your favorite alternatives if\nyou have one. For example, use a config file for Nix; or other method to install\nfrom AUR; pkgsrc can be use on OSes other than NetBSD etc._\n\n### Pre-built executable\n\nChoose an pre-built executable from the [release page][] that fits your\nplatform to download. Unpack it somewhere you'd like to run it from.\n\n[release page]: https://github.com/dduan/tre/releases\n\n### From Source\n\n1. Clone this repository: `git clone https://github.com/dduan/tre.git`.\n2. Ensure you have Rust and Cargo installed. If not, follow instruction [here](https://rustup.rs).\n3. In the root level of this repo, run `cargo build --release`.\n4. Move `target/release/tre` to somewhere in your PATH environment variable.\n\n## Editor aliasing\n\ntre provides a `-e` flag that, when used, turns on the \"editor aliasing\"\nfeature. Some shell configuration will make this work better.\n\n### macOS/Linux\nBy default, the environment variable `$EDITOR` is used as the editor. If a\nvalue following `-e` is supplied (`tre -e emacs` instead of `tre -e`), then\nthe command specified by this value will be used instead of `$EDITOR`. Update\nthe script in the next section accordingly.\n\n#### Bash or Zsh\n\nIn `~/.bashrc` or `~/.zshrc` (for example)\n\n```bash\ntre() { command tre \"$@\" -e \u0026\u0026 source \"/tmp/tre_aliases_$USER\" 2\u003e/dev/null; }\n```\n\n#### Fish\n\nCreate `~/.config/fish/functions/tre.fish`:\n\n```fish\nfunction tre\n  command tre $argv -e; and source /tmp/tre_aliases_$USER ^/dev/null\nend\n```\n\n### Windows (10+)\n\nInstead of directly executing `tre.exe`, we'll set up a script that's\navailable in your `PATH` environment variable. For example, you can add\n`\\Users\\yourname\\bin` to your `PATH` environment variable, and created the\nscript there. When you use `tre`, this script executes `tre.exe`, and do some\nadditional work. The content of the script is different for PowerShell and\nCommand Prompt.\n\nBy default, the default program known by Windows will be used to open the\nfile. If a value following `-e` is supplied (`tre -e notepad.exe` instead of\n`tre -e`), then the command specified by this value will be used. Update the\nscripts in the next section accordingly.\n\n#### PowerShell\n\nAdd a `tre.ps1` file:\n\n```ps1\nif (Get-Module PSReadLine) {\n  Remove-Module -Force PSReadLine\n}\ntre.exe $args -e\n. $Env:TEMP\\tre_aliases_$env:USERNAME.ps1\n```\n\n#### Command Prompt (CMD.exe)\n\nAdd a `tre.bat`:\n\n```\n@echo off\ntre.exe %* -e\ncall %TEMP%\\tre_aliases_%USERNAME%.bat\n```\n\n### How it works\n\nThe first thing you'll notice is some numbers in front of each file name in\ntre's output. If pick a number, say, \"3\", and enter `e3` in the shell, the file\nafter \"3\" will open in your default program (specified by the environment\nvariable `EDITOR` in macOS/Linux, and picked by Windows).\n\nEverytime tre runs with `-e`, it updates a file in a temporary directory, and\nadds an alias for each result it displays. And the additional configuration\nsimply sources this file after the command. You can manually run\n\nin Bash/Zsh/Fish:\n```bash\nsource /tmp/tre_aliases_$USER\n```\n\nor\n\nin PowerShell\n```ps1\n. $Env:TEMP\\tre_aliases_$env:USERNAME.ps1\n```\n\nor\n\nin Command Prompt\n\n```\ncall %TEMP%\\tre_aliases_%USERNAME%.bat\n```\n\n… instead of configuring your system (if you are _that_ patient!).\n\n## Everything else\n\nHere's the output from `tre -h`, showing all available options provided by tre:\n\n```\nUSAGE:\n    tre [OPTIONS] [PATH]\n\nARGS:\n    \u003cPATH\u003e    [default: .]\n\nOPTIONS:\n    -a, --all                   Print all files and directories, including hidden ones\n    -c, --color \u003cWHEN\u003e          When to color the output. `automatic` means when printing to a\n                                terminal, tre will include colors; otherwise it will disable colors\n                                [default: automatic] [possible values: automatic, always, never]\n    -d, --directories           Only list directories in output\n    -e, --editor [\u003cCOMMAND\u003e]    Create aliases for each displayed result, and add a number in front\n                                of file name to indicate the alias name. For example, a number \"42\"\n                                means an shell alias \"e42\" has been created. Running \"e42\" will\n                                cause the associated file or directory to be open with $EDITOR (or a\n                                default program for the file type on Windows), or a command\n                                specified along with this command\n    -E, --exclude \u003cPATTERN\u003e     Exclude paths matching a regex pattern. Repeatable\n    -h, --help                  Print help information\n    -j, --json                  Output JSON instead of tree diagram\n    -l, --limit \u003cLIMIT\u003e         Limit depth of the tree in output\n    -p, --portable              Generate portable (absolute) paths for editor aliases. By default,\n                                aliases use relative paths for better performance\n    -s, --simple                Use normal print despite gitignore settings. '-a' has higher\n                                priority\n    -V, --version               Print version information\n```\n\nIf you like the editor aliasing feature, you may want to check out [ea][].\n\n[ea]: https://github.com/dduan/ea\n\n## Packaging\n\n`tre` is a standard Cargo-managed Rust project.\nA unix manual is available at `manual/tre.1`.\nCompletion scripts for various shells are at `scripts/completion`.\n\n## License\n\nMIT. See `LICENSE.md`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdduan%2Ftre","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdduan%2Ftre","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdduan%2Ftre/lists"}