Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Automator service to clone Git repos in Mac Finder
# Use this to quickly create a git repo in a Mac Finder folder
#
# You need to create an Automator service:
# - Open Automator, choose to create a new Service
# - At the top, select Service receives selected "Folders" in "Finder"
# - From the list at the left, choose Library/Utilities, then drag the
# Run Shell Script action to the workarea
# - Paste the script below into the script area
# - Make sure you set the 'Pass input:' selection to "as arguments"
# - Save the service with an easy to find name, I used "Git Clone Here"
#
# To use:
# - Copy the repo path to your clipboard, like from a Github repo page
# - Right click on the folder where you want to store the repo
# - Choose Service from the menu, then "Git Clone Here" to clone the repo into the folder
#
# - It will notify you when done if you have the terminal-notifier app installed
# https://github.com/alloy/terminal-notifier
# Once you install terminal-notifier, you should check the location and update the
# NOTIFIERAPP value below appropriately
cd "$@"
REPOPATH=`pbpaste`
REPOFULL=$(basename "$REPOPATH")
REPONAME="${REPOFULL%.*}"
git clone $REPOPATH
NOTIFIERAPP="/usr/local/bin/terminal-notifier"
if [ -e $NOTIFIERAPP ]
then
$NOTIFIERAPP -title "Git Clone Completed" -message "Git repo '$REPONAME' has been cloned"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.