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
/opt/matlab-R2006b/toolbox/matlab/general/ls.m

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');
else
 [s,listing] = unix(['ls ', args{:}]);
end

into the nicer

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

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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s