[Solved] Tree as alias command

Hi, I have this command:

ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/   /' -e 's/-/|/'    

Works nicely to show the current file structure as a tree.

I'd like to have it as an alias in '' but doesn't work just like that and I can't fix it with backslashes:

alias tree='?'

Can someone help? Thanks

the simplest would be to put it in a file called dir (nothing more...)
then

alias dir='ksh $HOME/dir'

or whatever shell you are using...
or make your file executable and give it another name, the alias is just so you dont risk calling a program with the same name...

Depending on your shell, you can use a function:

tree () {
        ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/   /' -e 's/-/|/'
}
1 Like

Forgotten that possibility, thanks for reminding me...

Works perfectly, thanks!