Skip to content

Instantly share code, notes, and snippets.

@whytheplatypus
Created December 7, 2018 14:01
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 whytheplatypus/aacb221f36ead2d2e97952500973e689 to your computer and use it in GitHub Desktop.
Save whytheplatypus/aacb221f36ead2d2e97952500973e689 to your computer and use it in GitHub Desktop.
local script to mimic gist
#!/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
#!/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