SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2012-09-27 16:09:46

minerals
Member
Registered: 2012-09-26
Posts: 16

"ls" alternative?

Hi there, just got on board. I think I should share with my little script I use pretty frequently. It all started when I decided to study some bash. There was an exercise in the book so I went a little bit too far and it all turned out into a script that I use on daily basis. I love console apps so I hated how I had to tweak ls all the time for it to show dirs first and color the output. I hated when ls swallowed filenames with spaces that rendered it unusable in scripts, so I decided to get my hands dirty.

About the script. It is an ls alternative with some colors and additional info on the files. It can filter out video, audio, text and executable files (file extension independent). Can draw some pretty directory trees as well (mostly a useless function, but I still like it)

So, go ahead, give it a try if you feel like it. I keep it in /usr/local/bin

Screenshot: http://mountpeaks.files.wordpress.com/2 … x720sc.png
Here is the script: http://lls.googlecode.com/files/lls

Debian users might like changing “#!/bin/sh” to “#!/bin/bash” in the script

Last edited by minerals (2012-09-27 16:12:53)

Offline

Be excellent to each other!

#2 2012-09-27 16:36:07

zalew
#! Junkie
From: Warsaw, .PL
Registered: 2012-03-28
Posts: 374

Re: "ls" alternative?

minerals wrote:

Debian users might like changing “#!/bin/sh” to “#!/bin/bash” in the script

why?
not everyone uses bash. that's the point of linking to sh, which invokes your shell of choice.

Offline

#3 2012-09-27 16:46:25

minerals
Member
Registered: 2012-09-26
Posts: 16

Re: "ls" alternative?

I don't know, but for some reason #!/bin/sh does not work in Debian/Ubuntu distros, when #!/bin/bash does. I didn't have time and desire to deal with this issue as I used it in arch mostly, where it worked just fine.

Last edited by minerals (2012-09-27 16:47:22)

Offline

#4 2012-09-27 17:13:19

johnraff
nullglob
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 3,031
Website

Re: "ls" alternative?

It's probably because the script uses some feature of bash which isn't available in Debian's default shell, dash. If a script needs bash it should always specifically call for it with #!/bin/bash at the top. If you put #!/bin/sh you'll get dash in Debian, though maybe Arch is set up differently.


John
--------------------
( a boring Japan blog , idle twitterings  and GitStuff )
#! forum moderator

Offline

#5 2012-09-27 17:16:23

el_koraco
#!/loony/bun
From: inside Ed
Registered: 2011-07-25
Posts: 4,749

Re: "ls" alternative?

zalew wrote:

that's the point of linking to sh, which invokes your shell of choice.

AFAIK, sh is symlinked to bash in most distros, and to dash in Debian and derivatives.

Offline

#6 2012-09-27 17:34:42

zalew
#! Junkie
From: Warsaw, .PL
Registered: 2012-03-28
Posts: 374

Re: "ls" alternative?

el_koraco wrote:
zalew wrote:

that's the point of linking to sh, which invokes your shell of choice.

AFAIK, sh is symlinked to bash in most distros, and to dash in Debian and derivatives.

yeah, you are right. it invokes the system shell, not user's shell.

╰─$ file `which sh`
/bin/sh: symbolic link to `dash'

Offline

#7 2012-09-27 17:42:27

el_koraco
#!/loony/bun
From: inside Ed
Registered: 2011-07-25
Posts: 4,749

Re: "ls" alternative?

The problem, if one might call it so, is that Red Hat has sh symlinked to bash. Since it's the "industry standard" distro, most vendors write scripts in bash and invoke sh.

Last edited by el_koraco (2012-09-27 17:42:46)

Offline

#8 2012-09-27 19:30:25

rhowaldt
#!*$%:)
Registered: 2011-03-09
Posts: 4,396

Re: "ls" alternative?

if y'all are gonna discuss symlinks, i'll just take the opportunity to thank minerals for posting this script. his reasoning was solid, there are indeed some quite annoying things about ls, and i applaud him for writing his own version. great job minerals.

Offline

#9 2012-09-28 17:05:27

minerals
Member
Registered: 2012-09-26
Posts: 16

Re: "ls" alternative?

))
thanks, I shall be even more happy if anyone finds it useful.

As I said, ask if you have questions. The script creates a tiny config file .llsrc in ~/ so that you could change the colors for permissions if you don't like the defaults.

lls --help shall show you the basics

Last edited by minerals (2012-09-28 17:06:17)

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo