I wanted to make an alias cd that will immediately list the directories.
I tried all the following options:
alias 'cd'='cd $1; l' alias 'cd'='cd $1; l $1' alias 'cd'='cd $1 && l' alias 'cd'='cd $1 && l $1' Where, l (lowercase “L”) is the alias of another application ( tree ).
Always overloaded the terminal, so for sure, since
. ~/.bash_aliases. ~/.bash_aliasesfor some reason does not work for me.
All the above aliases when entering cd / list the list of directories / files at the mount point / , however, the directory does not change.
Then I tried to prescribe a function in the same .bash_aliases (both in turn ):
cd() { cd $1 l } function cd() { cd $1 l } As a result, when executing the cd / command "hangs" ...
The only way I found this is to do this:
cdl() { cd $1 l } That is, to set a different name ... But at the same time, if you go back to the first variant of the alias:
alias 'cd'='cd $1; l' This is where cd works when you enter cd / , since l lists the list of directories / files along the path / , so why does it return back to the home directory?