How to add functions to your Ubuntu or other Bash Terminal Shell
This is very useful.. just realized that I do so many repetitive things, eg:
cd config
ls -ltra
I thought, well I can just create a script like /usr/bin/cdl to do that, but that’s not going to work. Scripts are created in their OWN shell so you can’t use the “cd” command. It has no knowledge of the parent shell location.
So, the step is to create a function within the shell, and the easiest way to do that is create it in $HOME/.bashrc
Here’s the example above. The syntax is pretty standard and like shell scripting.
cdl()
{
cd ${1}
ls -ltra
}
Note you you have to open a new shell to see changes to bashrc



