-
-
Save whytheplatypus/aacb221f36ead2d2e97952500973e689 to your computer and use it in GitHub Desktop.
local script to mimic gist
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/bash | |
if [ $# -lt 1 ]; then | |
echo "Must supply a file name" | |
exit 1 | |
fi | |
REPO_NAME=$(echo "$1" | base64) | |
LOCAL_REPO=$HOME/.gist/$REPO_NAME | |
FILE_PATH=$(pwd)/$1 | |
mkdir -p $LOCAL_REPO | |
cd $LOCAL_REPO | |
GIT_STATUS=$(git status) | |
if [ $? -eq 0 ]; then | |
echo $REPO_NAME | |
else | |
echo "initializing git" | |
git init | |
ln $FILE_PATH $LOCAL_REPO | |
git add . | |
git commit -m "Initial commit" | |
if [ $# -eq 2 ]; then | |
git remote add local $2:$REPO_NAME.git | |
fi | |
exit 0 | |
fi | |
if [ $# -gt 1 ]; then | |
git ${@:2} | |
fi |
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 | |
if [ $# -lt 1 ]; then | |
echo "Must supply a file name and remote" | |
exit 1 | |
fi | |
REPO_NAME=$(echo "$1" | base64) | |
FILE_NAME=$1 | |
REMOTE_NAME=$2 | |
LOCAL_REPO=$HOME/.gist/$REPO_NAME | |
FILE_PATH=$(pwd) | |
cd $HOME/.gist | |
git clone $REMOTE_NAME:$REPO_NAME.git | |
ln -s $LOCAL_REPO/$FILE_NAME $FILE_PATH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment