# Substituting ls with ls -FGP system-wide?



## ph0enix (Mar 7, 2009)

I would like to substitute the ls command with 'ls -FGP' for all users and shells.  How should I go about doing that?

Thanks!

J.


----------



## DutchDaemon (Mar 7, 2009)

/etc/profile

alias ls='ls -FGP'

Inform your users, especially the ones working with symlinks ..


----------



## Mel_Flynn (Mar 7, 2009)

That only works for bourne-type shells. Use /etc/csh.cshrc for csh. Note that aliases can be overridden by users. If that's a concern, then move /bin/ls to /libexec/ls and make /bin/ls a shell script:

```
#!/bin/sh
exec /libexec/ls -FGP $*
```
Which you will have to do with after each installworld. Probably easier to maintain a local patch to ls, that will set -FGP, like:

```
--- ls.c        2008-04-03 19:57:46.000000000 -0800
+++ /tmp/ls.c   2009-03-07 07:38:08.000000000 -0900
@@ -340,6 +340,14 @@
        }
        argc -= optind;
        argv += optind;
+       /* Force -FGP */
+       f_type = 1;
+       f_slash = 0;
+       setenv("CLICOLOR", "", 1);
+       fts_options &= ~FTS_COMFOLLOW;
+       fts_options &= ~FTS_LOGICAL;
+       fts_options |= FTS_PHYSICAL;
+       /* End force -FGP */

        /* Root is -A automatically unless -I. */
        if (!f_listdot && getuid() == (uid_t)0 && !f_noautodot)
```


----------

