CdHereScript/Code

להלן הקוד של הסקריפט. נא לא לשנות את הקוד. מי שרוצה להציע שיפור שיוסיף את השיפורים למטה. אם הם ימצאו בטוחים ושימושים הם ישולבו בסקריפט זה. [[ltr]]

(*

A better Send Terminal Here

Open a terminal in the selected folder or the parent folder of the
selected file. The folder window could be open or close.

Installation: put in the scripts menue.

Note: If you select several items, it will use only the first one. This
can be unpredictable.


Nir Soffer
nirs at israsrv.net.il

*)

-- Get the first item in the finder selection
tell application "Finder" to set theItems to the selection
set thePath to item 1 of theItems as string

-- Is it a folder? - it should ends with :
if last character of thePath is not ":" then
  -- its not a folder - take the parent folder
  set AppleScript's text item delimiters to ":"
  set thePath to (text items 1 thru -2 of thePath) as string
end if

-- Convert the path to unix style path and quote it
-- it may contain spaces
set unixStylePath to "\"" & POSIX path of thePath & "\""

tell application "Terminal"
  -- Open terminal window and cd to the path
  activate
  do script with command "cd " & unixStylePath
  
  -- Then, after short delay, rename the terminal window 
  delay 1
  set name of front window to "Terminal"
end tell

[[rtl]] קטגוריות: קטגוריה: מק למתקדמים

last edited 2003-04-26 23:25:17 by bzq-118-115