Page 1 of 1

Creating new cd and ls function

Posted: Fri Feb 14, 2014 7:02 pm
by musicboy
Hi there.
I'm a fair beginner to the Pi, and have a question for the pi gods :)
The one thing that I find tedious when using the shell is doing "ls" after every time I do "cd". (I'm lazy)
Just wondering, how easy would it be to create a function combining cd and ls, say "cdl", that I could execute as one command?
And what file would I need to define it in?
Thanks very much for your patience with a beginner.

Re: Creating new cd and ls function

Posted: Fri Feb 14, 2014 9:44 pm
by colinh
This isn't really a Raspberry Pi question, let alone a Bare Metal one. It's a Unix question...

anyway, you want

function cdl { cd $1; ls; }

added to your .bash_profile file in your home directory.


Try typing man bash.

edit: if you actually *do* this, and read it all, you'll find out about command completion and filename completion etc. Try ls TAB-key TAB-key. Then try man ls and ls -A.

Re: Creating new cd and ls function

Posted: Fri Feb 14, 2014 10:56 pm
by redhawk
I quite like navigating and viewing text files with lynx although it's main function is text based web browsing.
To access your current directory lynx . is all you need. :)

Richard S.