mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-22 18:45:54 +01:00
Add support for multiple shell types. Fixes #184
Also add "rb" as an alias to rebuildPatches
This commit is contained in:
parent
e00a06201b
commit
13ca1593c5
30
paper
30
paper
@ -1,7 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# get base dir regardless of execution location
|
||||
# resolve shell-specifics
|
||||
case "$SHELL" in
|
||||
"/bin/zsh")
|
||||
RCPATH="$HOME/.zshrc"
|
||||
SOURCE="${BASH_SOURCE[0]:-${(%):-%N}}"
|
||||
;;
|
||||
*)
|
||||
RCPATH="$HOME/.bashrc"
|
||||
if [[ -f "$HOME/.bash_aliases" ]]; then
|
||||
RCPATH="$HOME/.bash_aliases"
|
||||
fi
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
;;
|
||||
esac
|
||||
# get base dir regardless of execution location
|
||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
@ -21,7 +34,7 @@ paperunstash() {
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
"rbp" | "rebuild")
|
||||
"rb" | "rbp" | "rebuild")
|
||||
(
|
||||
set -e
|
||||
cd "$basedir"
|
||||
@ -104,14 +117,16 @@ case "$1" in
|
||||
esac
|
||||
;;
|
||||
"setup")
|
||||
if [[ -f ~/.bashrc ]] ; then
|
||||
if [[ -f "$RCPATH" ]] ; then
|
||||
NAME="paper"
|
||||
if [[ ! -z "${2+x}" ]] ; then
|
||||
NAME="$2"
|
||||
fi
|
||||
(grep "alias $NAME=" ~/.bashrc > /dev/null) && (sed -i "s|alias $NAME=.*|alias $NAME='. $SOURCE'|g" ~/.bashrc) || (echo "alias $NAME='. $SOURCE'" >> ~/.bashrc)
|
||||
(grep "alias $NAME=" "$RCPATH" > /dev/null) && (sed -i "s|alias $NAME=.*|alias $NAME='.$SOURCE'|g" "$RCPATH") || (echo "alias $NAME='. $SOURCE'" >> "$RCPATH")
|
||||
alias "$NAME=. $SOURCE"
|
||||
echo "You can now just type '$NAME' at any time to access the paper tool."
|
||||
else
|
||||
echo "We were unable to setup the paper build tool alias: $RCPATH is missing"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
@ -120,7 +135,7 @@ case "$1" in
|
||||
echo "'setup' command. View below for details. For essential building and patching, you do not need to do the setup."
|
||||
echo ""
|
||||
echo " Normal commands:"
|
||||
echo " * rbp, rebuild | Rebuild patches, can be called from anywhere."
|
||||
echo " * rb, rbp, rebuild | Rebuild patches, can be called from anywhere."
|
||||
echo " * p, patch | Apply all patches to the project without building it. Can be run from anywhere."
|
||||
echo " * j, jar | Apply all patches and build the project, paperclip.jar will be output. Can be run from anywhere."
|
||||
echo ""
|
||||
@ -132,7 +147,7 @@ case "$1" in
|
||||
echo " | respectively to edit the correct project. Use the argument \"continue\" after"
|
||||
echo " | the changes have been made to finish and rebuild patches. Can be called from anywhere."
|
||||
echo ""
|
||||
echo " * setup | Add an alias to .bashrc to allow full functionality of this script. Run as:"
|
||||
echo " * setup | Add an alias to $RCPATH to allow full functionality of this script. Run as:"
|
||||
echo " | . ./paper setup"
|
||||
echo " | After you run this command you'll be able to just run 'paper' from anywhere."
|
||||
echo " | The default name for the resulting alias is 'paper', you can give an argument to override"
|
||||
@ -142,5 +157,8 @@ case "$1" in
|
||||
;;
|
||||
esac
|
||||
|
||||
unset RCPATH
|
||||
unset SOURCE
|
||||
unset basedir
|
||||
unset -f paperstash
|
||||
unset -f paperunstash
|
||||
|
Loading…
Reference in New Issue
Block a user