Skip to content

Instantly share code, notes, and snippets.

@1024jp
Last active October 1, 2015 04:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
open Terminal at the identical directory of the current document in CotEditor
(*
Go to Folder in Terminal Script for CotEditor
[description]
Open Terminal at the identical directory of current document in CotEditor.
[version] 1.1
[release] 2012-02-27
[lastmod] 2014-10-16
[author] 1024jp <http://wolfrosch.com/>
[licence] Creative Commons Attribution 4.0 International License
[usage]
put this script to '~/Library/Application Support/CotEditor/ScriptMenu/'
*)
-- __setting_______________________________________________________________
-- Shows dialog if the document wasn't saved?
property showAlertDialog : true
-- __main_______________________________________________________________
-- get file path from CotEditor
tell application "CotEditor"
if not (exists front document) then return
set theFile to file of front document
end tell
-- end script if no file path is specified
if theFile is missing value then
if showAlertDialog then
beep
display alert "No file path is specified." message "Please save the file first." as warning
return
end if
return
end if
-- get directory path
set dirPath to do shell script "dirname " & quoted form of (theFile's POSIX path)
-- open in terminal
tell application "Terminal"
do script "cd " & quoted form of dirPath
do script "ls -l" in front window
activate
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment