2022-01-01 18:24:20 -08:00
|
|
|
#!/bin/bash
|
2022-01-02 17:46:16 -08:00
|
|
|
# Source this and then run `gloned`
|
2022-01-01 18:24:20 -08:00
|
|
|
|
|
|
|
# Git cLONE cD
|
|
|
|
# Can take extra arguments for git (ex: gloned url:/repo folder)
|
|
|
|
|
|
|
|
# shellcheck disable=SC2068,SC2016
|
|
|
|
|
|
|
|
gloned() {
|
|
|
|
# remove the url up to the last segment, and remove the .git from the end
|
2022-01-02 17:46:16 -08:00
|
|
|
REPO_DIR="${2:-"$(echo "${1%.git}" | rev | cut -d '/' -f 1 | rev)"}"
|
2022-01-01 18:24:20 -08:00
|
|
|
|
2022-01-02 17:46:16 -08:00
|
|
|
git clone "$1" "$REPO_DIR" || return $?
|
2022-01-01 18:24:20 -08:00
|
|
|
if ! cd "$REPO_DIR";then
|
|
|
|
echo 'Error: Could not `cd` into the repo'
|
2022-01-02 17:46:16 -08:00
|
|
|
return 1
|
2022-01-01 18:24:20 -08:00
|
|
|
fi
|
|
|
|
echo
|
|
|
|
# ls --color=auto
|
|
|
|
}
|