Shell script to upload current folder to server
Upload current directory to special directory on hosting and copy link to clipboard. Skip .git
and node_modules
. Just tweak $server
, $remote
and $url
variables and add this function to your .bash_profile
.
function yay() {
server="locum" # Server (can be ~/.ssh/config alias)
dir=`basename "$(pwd)"`
remote="~/projects/yay/$dir" # Path on remote server
url="http://yay.sapegin.me/$dir/" # Public URL
tar cp --exclude '.git' --exclude 'node_modules' . | gzip | ssh $server "mkdir -p "$remote"; gzip -cd | tar x -C "$remote""
echo "Current directory uploaded to $url."
if command -v pbcopy >/dev/null 2>&1; then
echo -n "$url" | pbcopy
echo "URL copied to clipboard."
fi
}
Then you can just type yay
in any folder and it contents will be uploaded to http://yoursite.com/path/{dirname}/
.
Written by Artem Sapegin
Related protips
1 Response
Nice
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Shell
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#