I often want to open the entire directory I'm working in by using the mate
command, but how do I pass in the working directory itself?
For example, if I'm working in a rails app and I want to open the app folder into the TextMate tree, I would do mate app
, but how could I pass in the working directory itself (i.e. open the entire rails app in the tree)?
To print the name of the current working directory, use the command pwd . As this is the first command that you have executed in Bash in this session, the result of the pwd is the full path to your home directory.
The pwd command can be used to determine the present working directory. and the cd command can be used to change the current working directory.
~ - Your Home Directory When you open a new Terminal session, you start in a default location in your file system called your Home Directory.
To change to the current working directory's parent directory, type cd followed by a space and two periods and then press [Enter]. To change to a directory specified by a path name, type cd followed by a space and the path name (e.g., cd /usr/local/lib) and then press [Enter].
The command you might be looking for is
pwd
# Assign the current work directory to the bash script variable 'CWD'.
CWD=$(pwd)
# Print it.
printf "%s\n" ${CWD}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With