Snippet – Bash Function: Example Folder transversal
Posted on Jun 2, 2020
Just a quick post. If you need to pass arguments to a bash alias, well you can’t but! here is how you pass them using a simple bash function. In the example it will be a folder transversal to a base folder with option for input to a specific sub-folder.
#folder transversal for project folders
projects() {
cd "/mnt/d/projects/$1"
}
This function ‘projects’ moves to a specific top level folder on a second drive the “$1” gives the option to specify a sub-folder or sub-folder set within that base folder and move into it e.g. /mnt/d/projects/foo/bar.
Hope this helps someone!