Skip to content

Instantly share code, notes, and snippets.

@webcaetano
Created June 29, 2016 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webcaetano/24ff6dc79402a2f3e5af1c11f231a401 to your computer and use it in GitHub Desktop.
Save webcaetano/24ff6dc79402a2f3e5af1c11f231a401 to your computer and use it in GitHub Desktop.
#!/bin/bash
CD_CMD="cd "\\\"$(pwd)\\\"" && clear"
if echo "$SHELL" | grep -E "/fish$" &> /dev/null; then
CD_CMD="cd "\\\"$(pwd)\\\""; and clear"
fi
VERSION=$(sw_vers -productVersion)
OPEN_IN_TAB=0
OPEN_TYPE="window"
while [ "$1" != "" ]; do
PARAM="$1"
VALUE="$2"
case "$PARAM" in
--open-in-tab)
OPEN_IN_TAB=1
;;
esac
shift
done
if (( $(expr $VERSION '<' 10.7) )); then
RUNNING=$(osascript<<END
tell application "System Events"
count(processes whose name is "iTerm")
end tell
END
)
else
RUNNING=1
fi
osascript &>/dev/null <<EOF
tell application "iTerm"
tell (create window with default profile)
tell the current session
write text "$CD_CMD"
end tell
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment