Skip to content

Commit 3e587e4

Browse files
committed
fix: multiple remotes repo open
1 parent 3511bff commit 3e587e4

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

git-open.zsh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@ trim() {
2222
}
2323

2424
git_get_remote() {
25-
remote=$(git remote -v | grep "(push)" | awk '{print $2}')
26-
echo $remote
25+
remote=$(git remote -v | grep "(push)" | awk '{print $1, $2}')
26+
# Prefer "origin" remote if available, otherwise use the first one
27+
selected=$(echo "$remote" | grep "^origin " | head -1 | awk '{print $2}')
28+
if [[ -z "$selected" ]]; then
29+
selected=$(echo "$remote" | head -1 | awk '{print $2}')
30+
fi
31+
echo $selected
2732
}
2833

2934
git_get_repo_path() {

0 commit comments

Comments
 (0)