Skip to content

EvgeniGenchev/lss

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Ls

A simple replacement for gnu-ls written in C that allows for some customization.

image

Requirements

It should work on any UNIX x86 system :)

Features

  • list files data
    • colored file name based on type
    • date of last edit
    • size in human readable format
    • support for ls's -a and -A flags
  • Configurable through config.h
  • install script

How to customize

Similar to suckless software the script is contained in cofing.h file where you can customize your color palette and extend functionality.

In order to, customize the your lss you need to locate the main.c file in the repository directory and open it with an editor of choice. There are 4 common customizations.

  1. Change the color palette;

    This can be done by editing the COLOR_XXX definitions:

    image

    NOTE: DO NOT CHANGE THE COLOR_RESET VALUE

  2. Add more types of a category to be colored:

    This can be done by including more char * in the XXX_ARRAY definitions and then increasing/decreasing the defined length of the array XXX_ARR_LEN. (I am aware setting array length by hand is dumb, however ***~Felt lazy, might patch later ~***):

    image

  3. Add more categories

​ In order to add a new category you need to do 3 operations

  • Define a new COLOR_XXX and XXX_ARR_LEN
  • Initialize a new global array:
#define COLOR_FONTS #6633FF

#define FONTS_ARR_LEN 4

char * FONTS_ARRAY[] = {".ttf", '.otf', '.ps', '.woff'}
  • Finally, add the custom array in the default case of the switch statement on line 224:

    		switch((S_IFMT & st.st_mode)){ // line 224
    			case S_IFDIR:
    				print_colored(entries[i]->d_name, COLOR_DIR);
    				break;
    			//some switch cases
    
    			default: // line 250
    				if (st.st_mode & S_IXUSR){
    					print_colored(entries[i]->d_name, COLOR_SH);
    				}
    				else{
    					// some if-else statements
    					else if (typeChecker(entries[i]->d_name, FONTS_ARRAY, FONTS_ARR_LEN)){
    						print_colored(entries[i]->d_name, COLOR_FONTS);
    					}
                        // some other if statemetns
    				}
    				break;
    1. Customize the output border

      image

      In order to, to do so you can change the definition of BORDER_CHAR to your desired character. There is support for non-ascii characters, however make sure you they are Monospace.:

Install

In order to install lss run the install.sh script located in the repository:

$ sudo ./install.sh

Alternatively, you can compile the installation manually:

$ gcc main.c -o lss
$ sudo cp lss /usr/bin/.

About

ls alternative written in C

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published