colors by default in matlab ls

In the matlab interpreter, you can give the ls command any modifier you would give the standard command-line ls: for instance ls --color will display the content of a given folder in colors (for instance, other folders in blue, etc), which is prettier and easier to parse visually. Unfortunately, there’s no built-in way to ask matlab to use the “–color” modifier by default, and all this typing becomes boring pretty fast.
Fortunately, the solution is pretty easy: the which command will show you the location of the source for any function, including ls.m :

>> which ls

You can then copy this function in your $HOME/matlab directory and modify it directly, changing for instance

if nargin == 0
 [s,listing] = unix('ls');
 [s,listing] = unix(['ls ', args{:}]);

into the nicer

if nargin == 0
 [s,listing] = unix('ls -pX --color');
 [s,listing] = unix(['ls -pX --color ', args{:}]);

It is just as easy to create the corresponding ll.m function.

This entry was posted in Technology and tagged , . Bookmark the permalink.

2 Responses to colors by default in matlab ls

  1. zewdu says:

    please send me free simulink CD
    thank you

  2. Julien says:

    Thanks ! Useful, for -F.

Comments are closed.