How to open an app in terminal and passing the cur

2019-06-15 04:05发布

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

7条回答
We Are One
2楼-- · 2019-06-15 04:30
DIR=$(readlink -f $0);
IFS='/' read -a array <<< "$DIR";
apath=("${array[@]:0:${#array[@]}-1}");
rpath=$(IFS=/ ; echo "${apath[*]}");
cd $rpath
查看更多
家丑人穷心不美
3楼-- · 2019-06-15 04:32
mate `pwd`/yourfile

mate `pwd`/app

Or you can using mate $PWD/app

查看更多
我欲成王,谁敢阻挡
4楼-- · 2019-06-15 04:32

The current working directory as set by the cd command is available in shell variable PWD, e.g.

echo $PWD
查看更多
爷、活的狠高调
5楼-- · 2019-06-15 04:34

The command you might be looking for is

pwd
查看更多
够拽才男人
6楼-- · 2019-06-15 04:40
# Assign the current work directory to the bash script variable 'CWD'.
CWD=$(pwd)

# Print it.
printf "%s\n" ${CWD}
查看更多
Viruses.
7楼-- · 2019-06-15 04:52

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)
查看更多
登录 后发表回答