I am developing on a windows machine. The only place I need for linux command line is Git Bash. The problem is: When I open it, I am in the home directory. I have to change the directory to my workspace, like:
cd ../../../d/work_space_for_my_company/project/code_source
Can I wrap this in a .sh file so I don’t have to hand-type it anymore? This should be simple but I have zero knowledge about Linux command line. I am really appreciated If you can walk me
through how to create that .sh file.
Just write that line to a file “cd.sh”, then do this from your shell prompt:
Or you can create an alias or function in your
$HOME/.bashrcfile:If the directory name includes spaces or other shell metacharacters, you’ll need quotation marks; it won’t hurt to add them even if they’re not necessary:
(Note that I’ve omitted the
../../..; you don’t need it.)EDIT: If you add a line
to your
.bashrcafter the function definition, your shell will start in that directory. Or you can just use thecdcommand directly in your.bashrcif you aren’t going to need to use the function later.(The name
foois just an example; you should pick a more meaningful name.)