How To Use "ls" In Color

From WebOS Internals

Jump to: navigation, search

You may also want to check out Colorful Bash Prompt.

Contents

Coreutils Method:

Prerequisites:

1) Rooted Pre

2) Ipkg-opt & unprivileged user installed & configured

3) Dropbear/OpenSSH installed

4) Connect & Log Into the Pre

Assumptions:

1) You are using PuTTY to connect to the Pre

2) You have made a SSH connection to the Pre.

Installing Coreutils in user mode:

Make sure ipkg-opt is up to date

1)  sudo ipkg-opt update

Install coreutils to /opt/bin

2)  sudo ipkg-opt install coreutils

Add an ls alias in /home/root/.profile or /etc/profile.d/optware-coreutils

3)  Add the following line:  alias ls='/opt/bin/ls --color'

Test your changes by logging out and log back in

4)  exit
5)  reconnect to your Pre & log in
6)  ls -l /

If the directories in / are dark blue, you have succeeded!

Rationale

Use of 'ls' segfaults as root with BusyBox when combined with --color (see above notes). rwhitby and eno helped to resolve this through the use of Coreutils, which takes up just slightly more space than busybox and can be more useful on Linux systems. Credit: ultraBlack

BusyBox Method:

If you've been spoiled by other Linux OS distros that use color to help easily identify files & directory structures, and found the Pre to be somewhat wanting in this area, read on:

Prerequisites:

1) Rooted Pre

2) Ipkg-opt & unprivileged user installed & configured

3) Dropbear/OpenSSH installed

4) Connect & Log Into the Pre

Assumptions:

1) You are using PuTTY to connect to the Pre

2) You have made a SSH connection to the Pre

Installing Busybox in User mode:

Make sure ipkg-opt is up to date

1)  sudo ipkg-opt update

Install busybox to /opt/bin

2)  sudo ipkg-opt install busybox

Verify /opt/bin is in your path

3)  echo $PATH

# If /opt/bin is listed in the path, then you have correctly fulfilled prerequisite #2 
# Example: /usr/local/bin:/usr/bin:/bin:/opt/bin

4)  sudo alias ls='/opt/bin/ls --color'

# It is not necessary to add alias to /etc/profile or /etc/profile.d/optware.
# The alias will persist after rebooting the Pre, however a WebOS 
# update may require the alias to be made once more.

Test your changes by logging out and log back in

5)  exit
6)  reconnect to your Pre & log in
7)  cd /
8)  ls

If the directories are dark blue, you have succeeded! Should the changes not apply, reboot the Pre. If it still doesn't work, go back to step 1 and try again.

Optionally, if you want ls to display in color while logged in as root (sudo su -)..

9)  sudo su -
10)  cd /bin
11)  mv ls ls.old
12)  ln -s /opt/bin/busybox /bin/ls
13)  ls

Caveats:

If you "sudo su -" without applying the above change and attempt to run /opt/bin/ls --color, it will segfault. See above. Rwhitby, eno, and ultraBlack have confirmed this bug. This does not affect user mode; only as root in a specific circumstance.

(Needs Verification) If you upgrade your WebOS, you may need to repeat steps 8-12 again to enable color as root user.

Rationale:

There are several issues with Palm's implementation of busybox, including the inability to specify --color. Palm's busybox will error out. This method is designed to give user mode color while root gets the default B&W //unless you apply the optional root change//. Following steps 1-7 will allow root to behave as if busybox-opt wasn't installed.

How To Undo:

User mode color

1)  sudo ipkg-opt remove busybox

Root user color

1)  Do step 1 above 
2)  sudo su -
3)  cd /bin
4)  rm ls
5)  mv ls.old ls
6)  ls
Personal tools
Google AdSense