Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open an app in terminal and passing the current working directory?

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)?

like image 505
Alex Coplan Avatar asked Dec 26 '11 11:12

Alex Coplan


People also ask

How do you get to the working directory in terminal?

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.

Which command is used for current working 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.

What is the current directory your terminal session started in?

~ - Your Home Directory When you open a new Terminal session, you start in a default location in your file system called your Home Directory.

How do I change the current working directory in Linux?

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].


2 Answers

The command you might be looking for is

pwd
like image 89
JohnRos Avatar answered Oct 19 '22 05:10

JohnRos


# Assign the current work directory to the bash script variable 'CWD'.
CWD=$(pwd)

# Print it.
printf "%s\n" ${CWD}
like image 43
alk Avatar answered Oct 19 '22 05:10

alk