- 创建 vim.app 到应用程序目录:
vim.app 代码如下
on run {input}
if length of input is equal to 1 then
my openFile(input)
else
my justOpen()
end if
end run
on openFile(input)
set the_file to quoted form of POSIX path of input
tell application "System Events"
set the_path to POSIX path of (container of (item 1 of input))
end tell
set cwd to "cd " & the_path
set cmd to "vim " & the_file
my launchVim(cwd, cmd)
end openFile
on justOpen()
set cwd to "cd"
set cmd to "vim"
my launchVim(cwd, cmd)
end justOpen
on launchVim(cwd, cmd)
tell application "System Events" to set terminalIsRunning to exists application process "Terminal"
tell application "Terminal"
activate
if terminalIsRunning is true then
tell application "System Events" to tell process "Terminal" to keystroke "t" using command down
do script with command cwd in selected tab of the front window
do script with command cmd in selected tab of the front window
else
do script with command cwd in window 1
do script with command cmd in window 1
end if
end tell
end launchVim
- 创建服务