[フレーム]
Last Updated: February 25, 2016
·
1.807K
· sapegin

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}/.

1 Response
Add your response

Nice

over 1 year ago ·

AltStyle によって変換されたページ (->オリジナル) /