Giter Site home page Giter Site logo

ft_select's Introduction

FT_SELECT - @42Born2Code

A robust file browser and manager in the terminal.

About

ft_select is the third project of the Unix branch at 42. The goal for this project is to learn more about screen oriented programs using termcap/terminfo libraries in the C programming language. It's originally just an argument viewer in the terminal but I decided to take it one step further and gave it browsing capabilities on the file system.

The main goal, however, is to build my own functional shell. Something like zsh and bash, this is what the next project at my school is about and ft_select is just a small part of it.

How to use it

Requirements

To be able to build and run this program, you'll need:

  • A Unix system
  • GNU make (v3.81)
  • GCC (v4.2.1)

Those are the versions used during development.

If you're on Linux, make sure you install

  • The termcap library:

      sudo apt-get install libncurses5-dev
    

Building

  1. Download/Clone this repo

     git clone https://github.com/r4meau/ft_select
    
  2. cd into the root directory and run make

     cd ft_select
     make
    

Running

A basic usage would involve at least one argument:

./ft_select hello

Features

  • If you pass a list of arguments to the program it gets displayed in your terminal.
  • You can move through the list using arrows.
  • One or more choices can be selected or un-selected with the space key. With each selection, the cursor will automatically position itself on the next element.
  • You can validate the selection with the return key, the list of choices will be sent back to the shell. This allows other programs to use the output of the program as their input. i.e: rm ./ft_select file1 file2 file3
  • Re-organizes the display on window resize or displays a blank screen if the list cannot fit the in window.
  • Exits on ESC key
  • Pressing the delete or backspace keys removes an element from the list. In Real mode (Read below), it will automatically delete the active element from the system if it's a valid file/folder. So watch out!
  • Press * to select all and - to unselect all.
  • Colored output based on some supported file extensions.
  • Pressing the keys O and B opens a valid folder and goes back to the parent root directory respectively.
  • Handles interruption signals gracefully (ctrl + z, ctrl + c, kill, etc...)
  • Restores the screen to what it was before clearing it.
  • No memory leaks
  • Whole codebase is commented for easier browsing.

Real mode

You can launch the program in real mode. In real mode, when you press delete/backspace on a valid file or folder, it will be deleted on the system too. So again, watch out! I'm not responsible for any loss of your files.

To run ft_select in real mode, use the flag -r or --real

./ft_select -r I love 42

TODO

  • Add breadcrumb
  • Press H to see hidden/dot files
  • Add copy and move capabilities
  • Even better error handling

NOTES

  • Don't mind the uneven tab widths, just set your editor's tab size to 4 (hard tabs, not soft) and it should be fine
  • You might not like the fact that I'm not adding curly braces for some if statements, curly braces add extra lines, and my school has a coding standard (The Norme) that you must follow to succeed the projects, this standard imposes some rules like 25 lines function limits etc... Read more about it here.
  • I added a second branch called original which is the original code of the program before I started norming the code. It will lack some extra features that I didn't add back then. It's here to show me how I code initially and will help me see how much I improve over time.

Resources

Here's a list of resources (in no particular order) I found useful to complete this project:

Acknowledgment

Thanks to my peers at 42, Christophe Gerbaudo (@cgerbaud) and Giacomo Guiulfo (@gguiulfo) who helped me go faster on this project by giving me some great tips.

Sponsors

Sponsor

Enjoy!

ft_select's People

Contributors

nickdotht avatar

Stargazers

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

Watchers

 avatar  avatar  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.