Last active
March 7, 2018 12:07
-
-
Save tinpark/d60d20ef7dd15cd5e5f453be44af59b4 to your computer and use it in GitHub Desktop.
This file contains 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/sh | |
# mkSymLink.sh | |
# | |
# | |
# Created by PARKER Martin on 06/03/2018. | |
# this cheesy little script makes a simlink to scripts you're sharing across computers (dropbox). Links are made inside /usr/local/bin so that you can call the scripts from Terminal anytime | |
# To get the path to dropbox on the different machines you use, I'm using this script to pull the path from the dropbox info.json file: cat ~/.dropbox/info.json | awk '{print $3}' | sed 's/[",]//g' || thanks to the comment from simgag here: https://forum.keyboardmaestro.com/t/path-of-the-dropbox-folder/2214/6 | |
# usage >> bash mkSymLink.sh shellScripts || shellScripts is an argument specifying the path on dropbox where you keep your folder of shell scripts | |
# first execute the search for the dropbox path and store inside DROPBOX_PATH: | |
# when you've got DROPBOX_PATH run the script recusively for each .sh file in the folder | |
# SYM links will be made in /usr/local/bin, if they're already there, the terminal will tell you and not make another | |
# The script requires an argument which is the folder within dropbox where you keep your scripts. You don't need to give slashes to the argument as these are wired into the script, if you have a subfolder, then you need to do this : bash mkSimLink.sh scripts/shell/fun where you have a folder called fun, inside shell, inside scripts, inside Dropbox. | |
# Remember don't use spaces in your file names if you can help it. | |
# finally, here's the script | |
DROPBOX_PATH=$(cat ~/.dropbox/info.json | awk '{print $3}' | sed 's/[",]//g') | |
for i in *.sh | |
do | |
t=${i##*/} | |
ln -s $DROPBOX_PATH/$1/"$i" /usr/local/bin | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment