zsh: add mkrepo helper
This commit is contained in:
parent
af2c65a03f
commit
26abe6efdb
1 changed files with 18 additions and 0 deletions
|
|
@ -24,6 +24,24 @@ alias clip='xclip -selection clipboard'
|
|||
alias copy='clip'
|
||||
function mkcd { mkdir -p $1 && cd $1 }
|
||||
function mkcode { mkcd $1 && code $1 }
|
||||
function mkrepo {
|
||||
setopt local_options err_return
|
||||
if [[ "$1" == "https://"* ]]; then
|
||||
# $1 is a remote URL, strip scheme and .git extension if any
|
||||
repoPath="$HOME/src/${${1/#https\:\/\/}/%.git}"
|
||||
repoRemoteURL="$1"
|
||||
git clone "$repoRemoteURL" "$repoPath"
|
||||
cd "$repoPath"
|
||||
else
|
||||
# $1 is a relative path within ~/src
|
||||
repoPath="$HOME/src/$1"
|
||||
repoRemoteURL="https://$1.git"
|
||||
mkdir -p "$repoPath"
|
||||
cd "$repoPath"
|
||||
git init
|
||||
git remote add origin "$repoRemoteURL"
|
||||
fi
|
||||
}
|
||||
|
||||
# Alias `code` to `code -r` if we're in the integrated terminal
|
||||
if [ "$TERM_PROGRAM" = "vscode" ]; then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue