Git Product home page Git Product logo

dir-explorer's Introduction

dir_explorer

CLI tools for quickly exploring the directory structure.

They were tested to work on macOS and Ubuntu in ZSH.

list_files.py

A script that piggy bags on the output of ls by adding colors on top of it. It allows to gray out unimportant files and to associate some colors with certain file extensions.

Configuration

You can customize the colors by editing the color_definitions.py file

Additionally, if you are not on macOS, you would have to modify the ls command as it has different parameters depending on the system.

To do so, open the dir_explorer/list_files.py file and modify the ls variable to a command that should be used as a basis. The command should have the flags necessary to output the files in the long format.

Installation

This tool does not have any dependencies.

The only think you would want to do is to add this to your .bashrc/.zshrc file:

alias l="python3 ~/path/to/dir_explorer/dir_explorer/list_files.py"

Additionally, you could customize the ls variable in dir_explorer/list_files.py to customize the default arguments that get passed to the ls command. By default, it calls ls command on Linux and gls on macOS.

Remember to change ~/path/to/dir_explorer/ to an actual path.

Usage

Then you can just press l in the terminal, hit ENTER, and look in awe at all the colors!

And just like with regular ls command, you can provide a directory name as the second parameter. You can even use a wildcard or multiple directories. Example:

l ~/Downloads/*.png ~/Documents/

Or display files recursively:

l -R ~/Downloads

list_view.py

list_view.py aims to provide an experience similar to Finder's list view right in your terminal. It is most useful for when you need to explore several directories and quickly move between levels as you search for the thing you are looking for.

Configuring

You can customize the colors by editing the color_definitions.py file.

Additionally, you can set the environmental variable EDITOR to a CLI editor you want to use for opening text files

Installing

Create a virtual environment:

python -m venv venv

If you choose to omit the creation of virtual environment, then you would have to change the location of python executable in dir_explorer/list_view.

Run pip install:

./venv/bin/pip install -r requirements.txt

Then, add the f bash function that is defined in ./dir_explorer/list_view to your ~/.zshrc. Alternativelly, you can source that file directly.

Don't forget to change the script_dir variable to the location of ./dir_explorer/list_view

Running

Then you can call f or f <some path> to display a directory in a list view.

Controls:

  • Up / Down Arrow - navigate Up / Down
  • Left / Right Arrow - open parent / child directory

Instead of the arrow keys, you can also use WSAD or HJKL.

Next, you can cd to the selected directory by pressing the Space key.

For opening files, you can use E to open it in the text editor, O for opening it in the default application, or Space bar to use the best application for that file type.

Additionally, macOS users can press the P key to quickly preview the file or directory.

Customize color definitions

After that, feel free to modify the dir_explorer/color_definitions.py as you see fit. That file defines the colors to use for each file type.

For color codes in modern terminals, see this nice article.

The color_definitions.py file contains a dictionary color_definitions that associates a human-friendly label with one of the 255 colors.

Then, in known_file_extensions, file extensions are assigned a certain color.

Also, for extensions like .zshrc, .eslitrc and other rc files, there is a useful known_file_extension_endings dictionary that defines colors for files whose extensions end with a given string. Finally, there is a known_file_names dictionary for when you need to associate an entire file name with a color.

dir-explorer's People

Contributors

maxpatiiuk avatar

Stargazers

Roman avatar

Watchers

James Cloos avatar  avatar

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.