1
txl263 2015 年 6 月 12 日
locate BBB|grep AAA
|
2
txl263 2015 年 6 月 12 日
Alfred里可以先输入BBB,焦点包含BBB的目标文件夹,→(方向键)然后输入AAA
|
3
txl263 2015 年 6 月 12 日
spotlight的话,输入BBB找到目标文件夹,然后焦点倒是可以显示内容,但是不知道怎么搜索AAA。
|
4
lululau 2015 年 6 月 12 日
`mdfind -name basename | fzf`
|
5
txl263 2015 年 6 月 12 日
find PATH -ipath '*BBB*AAA*'
|
6
pbjacob OP |
8
txl263 2015 年 6 月 13 日
@pbjacob find PATH -ipath '*BBB*AAA*' 和Alfred应该比较好,mdfind的话找不到APP包里的文件。当然find不如mdfind效率高(因为已经有数据库了)。
|
10
pbjacob OP @txl263 我还是希望能根据显示的检索结果直接能预览文件或打开文件或打开路径,就像Alfred或Spotlight的File Navigation一样。我考虑写个workflow给alfred吧。
|
11
txl263 2015 年 6 月 13 日
@pbjacob
find PATH -ipath '*BBB*AAA*' -print0 | xargs open -a APPName 比如在当前目录下寻找并且用预览打开 find . -ipath '*BBB*AAA*' -print0 | xargs open -a Preview 当然用mdfind也行 mdfind BBB | grep -i AAA | xargs open -a APPName open命令的参数 Options: -a Opens with the specified application. -b Opens with the specified application bundle identifier. -e Opens with TextEdit. -t Opens with default text editor. |
12
txl263 2015 年 6 月 13 日
-print0可以去掉
|
13
txl263 2015 年 6 月 13 日
文件或者目录名有空格的时候不行
|
14
txl263 2015 年 6 月 13 日
多个结果的话加-print0只打开第一个,否则就打开所有结果。目前不知道怎么处理名字里的空格
|
15
txl263 2015 年 6 月 13 日
好了,空格的问题也解决了,命令如下
find . -ipath '*BBB*AAA*' | sed 's/[ ]/\\ /' | xargs open -a Preview 如果嫌麻烦写个脚本带入参数吧 |
16
txl263 2015 年 6 月 13 日
find . -ipath '*BBB*AAA*' | sed 's/[ ]/\\ /g' | xargs open -a Preview
加了个g替换所有的空格,不然只替换一次 |
18
txl263 2015 年 6 月 13 日
如果想打开文件所在目录的话再加个sed -r 's/(.*)\/.*/\1/'
find . -ipath '*BBB*AAA*' | sed 's/[ ]/\\ /g' |sed -r 's/(.*)\/.*/\1/'| xargs open 有个命令dirname,可是不能放在管道后面? |