forklift.plugin.zsh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # Open folder in ForkLift.app of ForkLift2.app from console
  2. # Author: Adam Strzelecki nanoant.com, modified by Bodo Tasche bitboxer.de
  3. # Updated to support ForkLift2 by Johan Kaving
  4. #
  5. # Usage:
  6. # fl [<folder>]
  7. #
  8. # Opens specified directory or current working directory in ForkLift.app
  9. #
  10. # Notes:
  11. # It assumes Shift+Cmd+G launches go to folder panel and Cmd+N opens new
  12. # app window.
  13. #
  14. # https://gist.github.com/3313481
  15. function fl {
  16. if [ ! -z "$1" ]; then
  17. DIR=$1
  18. if [ ! -d "$DIR" ]; then
  19. DIR=$(dirname $DIR)
  20. fi
  21. if [ "$DIR" != "." ]; then
  22. PWD=`cd "$DIR";pwd`
  23. fi
  24. fi
  25. osascript 2>&1 1>/dev/null <<END
  26. try
  27. tell application "Finder"
  28. set appName to name of application file id "com.binarynights.ForkLift2"
  29. end tell
  30. on error err_msg number err_num
  31. tell application "Finder"
  32. set appName to name of application file id "com.binarynights.ForkLift"
  33. end tell
  34. end try
  35. if application appName is running
  36. tell application appName
  37. activate
  38. end tell
  39. else
  40. tell application appName
  41. activate
  42. end tell
  43. repeat until application appName is running
  44. delay 1
  45. end repeat
  46. tell application appName
  47. activate
  48. end tell
  49. end if
  50. tell application "System Events"
  51. tell application process "ForkLift"
  52. try
  53. set topWindow to window 1
  54. on error
  55. keystroke "n" using command down
  56. set topWindow to window 1
  57. end try
  58. keystroke "g" using {command down, shift down}
  59. tell sheet 1 of topWindow
  60. set value of text field 1 to "$PWD"
  61. keystroke return
  62. end tell
  63. end tell
  64. end tell
  65. END
  66. }