diff --git a/scripts/gef-extras.sh b/scripts/gef-extras.sh index 6a5b31958..60dec4c22 100755 --- a/scripts/gef-extras.sh +++ b/scripts/gef-extras.sh @@ -5,19 +5,32 @@ # set -e +usage() { echo "Usage: $0 [-b ] [-p ]" 1>&2; exit 1; } + branch="main" -if [ "$1" = "dev" ]; then - branch="dev" - echo "set branch to dev" -fi +while getopts ":b:p:" o; do + case "${o}" in + b) + branch=${OPTARG} + ;; + p) + path=${OPTARG} + ;; + *) + usage + ;; + esac +done -if [ $# -ge 1 ]; then - DIR="$(realpath "$1")/gef-extras" - test -d "${DIR}" || exit 1 -elif [ -d "${HOME}/.config" ]; then - DIR="${HOME}/.config/gef-extras" +if [ -z "$path" ]; then + if [ -d "${HOME}/.config" ]; then + DIR="${HOME}/.config/gef-extras" + else + DIR="${HOME}/.gef-extras" + fi else - DIR="${HOME}/.gef-extras" + DIR="$(realpath "$path")/gef-extras" + test -d "${DIR}" || exit 1 fi git clone --branch ${branch} https://github.com/hugsy/gef-extras.git "${DIR}"