zsh: realized some things need to be functions
By that, I mean things that change my working directory need to be functions
This commit is contained in:
parent
cba8e92e1d
commit
06ab216290
11 changed files with 93 additions and 94 deletions
20
.config/shell/functions/gloned
Normal file
20
.config/shell/functions/gloned
Normal file
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
# 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
|
||||
REPO_DIR="${2:-"$(echo "${1%%.git}" | rev | cut -d '/' -f 1 | rev)"}"
|
||||
|
||||
git clone "$1" "$REPO_DIR" || exit $?
|
||||
ls
|
||||
if ! cd "$REPO_DIR";then
|
||||
echo 'Error: Could not `cd` into the repo'
|
||||
exit 1
|
||||
fi
|
||||
echo
|
||||
# ls --color=auto
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue