How to open an app in terminal and passing the current working directory?
Solution 1
mate .
will open the currently directory. I use the .
directory a lot, for example open finder for the current directory open .
.
Solution 2
The command you might be looking for is
pwd
Solution 3
# Assign the current work directory to the bash script variable 'CWD'.
CWD=$(pwd)
# Print it.
printf "%s\n" ${CWD}
Solution 4
Getting the current directory is as simple as typing pwd
, or echo $PWD
.
Now, if you want to open TextMate in a particular directory, you can do:
(cd /target/directory && mate)
Solution 5
mate `pwd`/yourfile
mate `pwd`/app
Or you can using mate $PWD/app
Alex Coplan
Hello! I'm a Computer Science student. I like all things computery, but am especially interested in Ruby (+Rails), Javascript, AI and NLP. I enjoy hacking, making anything web-related and have written a couple of iPhone apps. Other things I like: Music, especially the organ! Languages: I can speak quite a bit of German and I'm a beginner in Spanish. I have a slight obsession with Duolingo Also, before you downvote my post:
Updated on February 07, 2020Comments
-
Alex Coplan over 4 years
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)?