added functions for rename branch and switch remote (origin) and completion
This commit is contained in:
parent
b3136b4d32
commit
9a08154085
9
src/functions/parseArgs_switchRemote.sh
Normal file
9
src/functions/parseArgs_switchRemote.sh
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
parseArgs_switchRemote() {
|
||||||
|
echo "Switching remote to $1"
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "ERROR: Argument remote url is missing"
|
||||||
|
help switchRemote
|
||||||
|
else
|
||||||
|
REMOTE_URL=$1
|
||||||
|
fi
|
||||||
|
}
|
||||||
9
src/functions/renameBranch.sh
Normal file
9
src/functions/renameBranch.sh
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
renameBranch() {
|
||||||
|
local newBranchName=main
|
||||||
|
local currentBranchName=$(git rev-parse --abbrev-ref HEAD)
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
newBranchName=$1
|
||||||
|
fi
|
||||||
|
echo "Renaming $currentBranchName to $newBranchName"
|
||||||
|
git branch -m $currentBranchName $newBranchName
|
||||||
|
}
|
||||||
8
src/functions/switchRemote.sh
Normal file
8
src/functions/switchRemote.sh
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
switchRemote() {
|
||||||
|
local remote=origin
|
||||||
|
local remoteUrl=$REMOTE_URL
|
||||||
|
local branch=main
|
||||||
|
|
||||||
|
git remote remove $remote
|
||||||
|
git remote add $remote $remoteUrl
|
||||||
|
}
|
||||||
@ -5,7 +5,7 @@ _gt-completion()
|
|||||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
prevPrev="${COMP_WORDS[COMP_CWORD-2]}"
|
prevPrev="${COMP_WORDS[COMP_CWORD-2]}"
|
||||||
opts="mind pullAndMerge help config"
|
opts="mind renameBranch switchRemote pullAndMerge help config"
|
||||||
config="print set init"
|
config="print set init"
|
||||||
|
|
||||||
# TODO check if this is still the most efficient way to list help options
|
# TODO check if this is still the most efficient way to list help options
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user