Results 1 to 4 of 4

Thread: ls --colour; i.e. ls for non-Americans

  1. #1
    Join Date
    Feb 2007
    Beans
    77

    ls --colour; i.e. ls for non-Americans

    If you think the correct spelling of "color" is "colour," then here's a script to make the ls program agree with you:

    Code:
    #!/usr/bin/perl
    foreach(0..$#ARGV) {
        last if $ARGV[$_] eq "--";
        $ARGV[$_] =~ s/^--colour/--color/;
    }
    exec("/bin/ls",@ARGV);
    Put that in a text file called "ls", make it executable, and put it in your path somewhere before /bin (i.e. before the location of the real ls), and then start a new terminal to allow the path change to take effect.

    Now, try ls --colour=yes

    Enjoy!

    Note: You could make a copy of this script for any other program that takes the --color option, such as grep. If there is demand for it, I will make a generalized script for any executable.

  2. #2
    Join Date
    Sep 2006
    Location
    Cardiff Wales UK
    Beans
    107
    Distro
    Ubuntu Studio 22.04 Jammy Jellyfish

    Re: ls --colour; i.e. ls for non-Americans

    Nice one
    Bet you couldn't get bill gates to do that!!!

    cheers
    Bob

  3. #3
    Join Date
    Dec 2005
    Location
    Kingston, Ontario
    Beans
    1,919
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: ls --colour; i.e. ls for non-Americans

    That's a little excessive. Just make an alias in your ~/.bashrc that reads:
    Code:
    alias ls --colour='ls --color=auto'
    EDIT: Apparently you'd can't do that. Dumb.
    Last edited by ~LoKe; February 4th, 2008 at 01:45 AM.
    +Solace @DeviantArt | Awesome Guide | Beginners Team Member
    Canadian Forces 2007-present

  4. #4
    Join Date
    Feb 2007
    Beans
    77

    Re: ls --colour; i.e. ls for non-Americans

    Even if that did work, it wouldn't cover something like
    Code:
    ls -ld ~/Downloads --colour
    Also, would anyone be interested in a more general implementation of this? This would mean support for more commands (e.g. grep --colour) and more options (can't think of any examples).
    Last edited by Darwin Award Winner; February 4th, 2008 at 07:34 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •