diff --git a/src/functions/parseArgs_switchRemote.sh b/src/functions/parseArgs_switchRemote.sh new file mode 100644 index 0000000..195c791 --- /dev/null +++ b/src/functions/parseArgs_switchRemote.sh @@ -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 +} diff --git a/src/functions/renameBranch.sh b/src/functions/renameBranch.sh new file mode 100644 index 0000000..0f7420a --- /dev/null +++ b/src/functions/renameBranch.sh @@ -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 +} \ No newline at end of file diff --git a/src/functions/switchRemote.sh b/src/functions/switchRemote.sh new file mode 100644 index 0000000..a4cdb39 --- /dev/null +++ b/src/functions/switchRemote.sh @@ -0,0 +1,8 @@ +switchRemote() { + local remote=origin + local remoteUrl=$REMOTE_URL + local branch=main + + git remote remove $remote + git remote add $remote $remoteUrl +} diff --git a/src/gt-completion b/src/gt-completion index 8a4298f..7ec36af 100644 --- a/src/gt-completion +++ b/src/gt-completion @@ -5,7 +5,7 @@ _gt-completion() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" prevPrev="${COMP_WORDS[COMP_CWORD-2]}" - opts="mind pullAndMerge help config" + opts="mind renameBranch switchRemote pullAndMerge help config" config="print set init" # TODO check if this is still the most efficient way to list help options