Your terminal on lsd
First of all, sorry about the clickbait title, but I could not stop myself from using this overused joke. What I wanted to talk about in this article is about Peltoche/lsd.
lsd is a rewrite of the classic
ls command but with a few new and useful(IMO) features. I am the primary maintainer of this project as of now and thought I would go over some interesting features.
I have seen a few videos, blogs and podcasts that talk about
lsd, but almost all of them just tend to talk about colors and icons. While they are awesome, there is a lot more awesome features in lsd that you should check out.
Before we begin, let me show you how lsd looks for me.
If you use lsd or if you have seen the screenshot in the README, you can tell it is quite different. Btw, this article is nothing that a quick read of the
--help can't reaplace, but I thought I would highlight the things that I like. This is just gonna be a list of thing I like in no particular order.
In most cases when you use
ls -l command, you don't really need all the information it gives you. At least for me, what I need is usually just the date, size, permissions and the name of the file.
lsd lets you pick and choose just what you want.
You can pick and choose any of these in any order:
- permission: permissions for the file
- user: user name
- group: group name
- size: size
- date: date last modified
- name: file name
- inode: inode number
- links: number of hard links
For example, I can do something like
lsd --block date,name,size and get something like this:
Or let's say I don't care about the name, I just want the sizes ordered by date. I could use something like:
I am not necessarily saying this is useful, just that it is possible.
Another nice thing is its ability to do trees. This by itself is not that useful, but you can combine it with custom
blocks which becomes really powerful.
Also, you can always sort this by time or size or anything.
--date relative #
This is one of my favourite features. I find it easier to understand relative time than have an exact date in most cases as I can be sometimes ignorant of what day today is. With
--date relative I can continue to be ignorant and not fix the actual problem. It is possible that I am partial to this because this was one of the first features that I added in.
--permission octal #
This is one of the newest features and might not be in a release by the time you read this, but you should be able to get it if you build from master. This lets you view the permissions in octal instead of as read write execute thingies. Here is what it looks like as of now.
If you see the prompt, you will see that I am in the
octal-perm branch wile I was working on this post.
Size/date based colors #
If you haven't noticed already, both the size column and the date column changes colors based on what it contains. Size column changes color based on how big/small a file is and date column changes color based on when a file was last modified. The best part is that you can change all the colors used here via the config file.
Themeing and config file #
Building on the last one, we support having a config file for all your customizations. Any flags that you wanna set by default, you can add into the config file. You can always ignore the config file with
--ignore-config cli flag and start from scratch. You might have already seen me using that flag for the screenshots (I was too lazy to move my config file).
You can also theme lsd completely using the theme file. You can change the color of any block, and the differing levels of sizes or dates. I have a really muted theme as you might have seen from the initial screenshot. You can take a look at my config here.
Refer to the README to know what all options are available.
LS_COLORS. For those of you who don't know what it is, you can think of it as a common convention on how to color filenames. Using
LS_COLORS you can define what color a directory should be, what color symlinks should be, what color
*.md files should be, etc. Even better is that there is already people who have gone ahead and created different colorschemes. There are also tools that help you create custom color schemes. For example if you want absolutely everything color coded, you can use trapd00r/LS_COLORS. It will look something like this with all the icons.
Checkout these projects if you are interested:
Oh, almost forgot. We got icons, but you knew that already.
And I think I am gonna wrap up with that. Thanks to all the contributors of lsd and Peltoche for starting the project :D.