-
-
Save therealmarv/4d6442593261e2776d75 to your computer and use it in GitHub Desktop.
Open current directory in forklift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Open current directory in forklift 4 | |
# Adapted from https://gist.github.com/elentok/6218781 | |
# Adapted from comment https://gist.github.com/elentok/6218781#comment-891115 | |
# Added optional path argument and removed using the clipboard buffer. | |
set -e | |
if [ -z "$@" ]; then | |
absPath=`pwd` | |
else | |
pushd "$@" > /dev/null | |
absPath=`pwd` | |
echo $absPath | |
popd > /dev/null | |
fi | |
(cat<<EOF | |
if application "ForkLift" is not running then | |
# This will launch Forklift if it's not running | |
# (But it's not making it the frontmost/focused application) | |
activate application "ForkLift" | |
# We wait 1 second so that we're pretty sure ForkLift did launch | |
delay 2 | |
end if | |
# Give focus to ForkLift | |
# activate application "ForkLift" | |
tell application "ForkLift" | |
activate | |
delay 0.3 | |
set canOpenTab to "unknown" | |
tell application "System Events" | |
tell process "ForkLift" | |
# Open new window if none, or new tab if there is one open | |
# Please adjust menu bar item name according to your language setting (File is the Enlish first menu, e.g. in German it would be "Ablage") | |
set canOpenTab to enabled of menu item 5 of menu 1 of menu bar item "File" of menu bar 1 | |
if canOpenTab is true then | |
keystroke "t" using {command down} | |
else | |
keystroke "n" using {command down} | |
delay 0.2 | |
end if | |
# Using ForkLift's "Go to Folder" | |
keystroke "g" using {command down, shift down} | |
delay 0.5 | |
# keystroke "v" using {command down} | |
keystroke "$absPath" | |
# adjust if Forklift hangs here | |
delay 1.5 | |
keystroke return | |
end tell | |
end tell | |
end tell | |
EOF | |
) | osascript |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment