终端中快速定位到Finder的当前路径

今天看AppleScript看到的一篇有点意思的贴子

vi ~/.profile

xxx

source ~/.profile

下午完成了app打包ipa的service,看到一个对ipa重签名的service,这个不就是iResign吗?我借鉴了一下里面的一些语法。

[Mac]终端中快速定位到Finder的当前路径

平时工作会非常频繁的使用到命令行, 常见的场景是需要CD到Finder的当前路径操作, 或是打开命令行当前的路径.  后者通过 open .  即可打开. 而前者的操作就比较繁琐, 我需要先输入 cd[空格] ,然后将文件夹拖入到终端中.

在忍受了无数次拖拽后突然想到通过 AppleScript 来获取路径并传送到终端. 考虑过ruby,需要额外的gem支持.  考虑过用 objc 写个工具, 但随后发现个命令 osascript 能直接运行 AppleScript的代码 ,解脱!

tell application “Finder” to set myname to POSIX path of (target of window 1 as alias)

这段代码能将当前的Finder的路径输出,  可以使用 osascript -e ‘codes’ 来测试结果.

编辑 ~/.profile  (没有就创建一个), 添加如下代码

function cdf() # cd to finder's front's window's path
{
   path="`osascript -e 'tell application "Finder" to set myname to POSIX path of (target of window 1 as alias)' 2>/dev/null`"
   if [ -n "$path" ]; then
      echo "cd to $path"
      cd "$path"
   else
      echo "no finder window finded"
   fi
}

然后source下此文件, 以后只要直接输入 cdf (cd-finder or cd-front 反正很好记) 即能切换到当前路径中.

用AppleScript设置Adium的状态信息

找了下找到个比较挫的办法

tell application "Adium"
	go away with message "Busy"
end tell

但是必须指定鸭子的状态, 最后翻了下文档自己写了段测试成功:

tell application "Adium"
	set the title of every status to "funny"
	set the status of every account whose status type is not offline to the first status whose title is "funny"
	#   也可以这么写
	#	repeat with state in every status
	#		set title of state to "come on baby"
	#	end repeat
end tell

也许下版本 LessDJ 会多个同步歌曲信息到 鸭子状态的功能 

对了 LessDJ 上线一周下载2000多次了, 但最近状态低迷, 需要些时间来添加新功能.

你可能感兴趣的:(find)