Add pre-script to switch to correct directory for each command

Signed-off-by: Billy Brawner <billy@wbrawner.com>
This commit is contained in:
Billy Brawner 2019-12-22 16:50:02 -06:00
parent 7c408d6d70
commit 9eae3ed258
8 changed files with 20 additions and 0 deletions

2
delete
View file

@ -1,5 +1,7 @@
#!/usr/bin/env sh #!/usr/bin/env sh
source "$(dirname "$0")/pre-script"
if [[ -z "$1" ]]; then if [[ -z "$1" ]]; then
echo "Please enter a repository name" echo "Please enter a repository name"
exit 1 exit 1

View file

@ -1,5 +1,7 @@
#!/usr/bin/env sh #!/usr/bin/env sh
source "$(dirname "$0")/pre-script"
if [[ -z "$1" ]]; then if [[ -z "$1" ]]; then
echo "Please enter a repository name" echo "Please enter a repository name"
exit 1 exit 1

2
ls
View file

@ -1,4 +1,6 @@
#!/usr/bin/env sh #!/usr/bin/env sh
source "$(dirname "$0")/pre-script"
for repo in $(/usr/bin/find -maxdepth 1 -type d -name "*.git"); do /usr/bin/basename $repo .git; done | sort for repo in $(/usr/bin/find -maxdepth 1 -type d -name "*.git"); do /usr/bin/basename $repo .git; done | sort

2
mirror
View file

@ -1,5 +1,7 @@
#!/usr/bin/env sh #!/usr/bin/env sh
source "$(dirname "$0")/pre-script"
if [[ -z "$1" ]]; then if [[ -z "$1" ]]; then
echo "Please enter a repository URL" echo "Please enter a repository URL"
exit 1 exit 1

View file

@ -1,5 +1,7 @@
#!/usr/bin/env sh #!/usr/bin/env sh
source "$(dirname "$0")/pre-script"
mkdir "$1" mkdir "$1"
( (
cd "$1" cd "$1"

2
new
View file

@ -1,5 +1,7 @@
#!/usr/bin/env sh #!/usr/bin/env sh
source "$(dirname "$0")/pre-script"
if [[ -z "$1" ]]; then if [[ -z "$1" ]]; then
echo "Please enter a repository name" echo "Please enter a repository name"
exit 1 exit 1

View file

@ -1,5 +1,7 @@
#!/usr/bin/env sh #!/usr/bin/env sh
source "$(dirname "$0")/pre-script"
REPO="$1" REPO="$1"
if [[ -z "$REPO" ]]; then if [[ -z "$REPO" ]]; then

6
pre-script Normal file
View file

@ -0,0 +1,6 @@
#!/usr/bin/env sh
REPO_DIR=/pub/git
cd $REPO_DIR