Skip to content

Commit

Permalink
Add installation script
Browse files Browse the repository at this point in the history
  • Loading branch information
extsoft committed Aug 21, 2017
1 parent d9b2383 commit 4b3c473
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ Allows easy handle git tasks.

[![Rultor.com](http://www.rultor.com/b/extsoft/elegant-git)](http://www.rultor.com/p/extsoft/elegant-git)

Installation
============
Manual
------
`curl https://raw.githubusercontent.com/extsoft/elegant-git/master/install.bash | $(which bash)`

For development
---------------
1. clone the repository
2. run `./install.bash dev`

Usage
=====
```bash
Expand Down
61 changes: 61 additions & 0 deletions install.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env bash -e

[ -z "$INSTALL_PATH" ] && INSTALL_PATH="$HOME/.git-elegant"
[ -z "$REPO_HOME" ] && REPO_HOME="https://github.com/extsoft/elegant-git.git"

man() {
echo "Usage: ./install.bash [remote|dev|uninstall]"
echo " - remote - install from GitHub (default)"
echo " - dev - install from local copy"
echo " - uninstall - remove current installation"
echo ""
echo "Configuration:"
echo " INSTALL_PATH=$INSTALL_PATH"
echo " REPO_HOME=$REPO_HOME"
}

run() {
echo "$1"
eval "$1"
}

install() {
echo "Installing 'elegant git' to $INSTALL_PATH"
run "rm -rfv $INSTALL_PATH"
run "mkdir -p $INSTALL_PATH"
if [ $1 = 'remote' ]; then
run "git clone --depth 1 $REPO_HOME $INSTALL_PATH"
cd "$INSTALL_PATH"
rm -rf .git
elif [ $1 = 'dev' ]; then
cp -rv $(dirname "$0")/* $INSTALL_PATH
else
echo "Unexpected mode: $1"
fi

run "mkdir -p $INSTALL_PATH/bin"
run "mkdir -p $INSTALL_PATH/completion"
run "mv $INSTALL_PATH/src/main/git-elegant-completion $INSTALL_PATH/completion"
run "mv $INSTALL_PATH/src/main/git-elegant* $INSTALL_PATH/bin"

echo ""
echo "Add the following to your .bash_profile to allow:"
echo "# extend 'git' with 'elegant git' commands"
echo "export PATH=$INSTALL_PATH/bin:\$PATH"
echo "#'elegant git' completion"
echo "[ -f $INSTALL_PATH/completion/git-elegant-completion ] && . $INSTALL_PATH/completion/git-elegant-completion"
echo ""
echo "Then please restart the terminal and enjoy the 'pem'!"
}

uninstall() {
echo "Uninstalling pem from $INSTALL_PATH"
run "rm -rfv $INSTALL_PATH"
}

case "$1" in
uninstall) uninstall ;;
help) man ;;
dev) uninstall && install dev ;;
*) uninstall && install remote ;;
esac

0 comments on commit 4b3c473

Please sign in to comment.