Skip to content

Instantly share code, notes, and snippets.

@jdraths
Forked from donarb/GitCloneHere.sh
Last active January 22, 2021 15:19
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 jdraths/42da77fe7d98a8c4090efb2d76636ce5 to your computer and use it in GitHub Desktop.
Save jdraths/42da77fe7d98a8c4090efb2d76636ce5 to your computer and use it in GitHub Desktop.
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 pull $REPOPATH
git pull
# NOTIFIERAPP="/usr/local/bin/terminal-notifier"
# if [ -e $NOTIFIERAPP ]
# then
# $NOTIFIERAPP -title "Git Pull Completed" -message "Git repo '$REPONAME' has been pulled"
# fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment