]> git.phdru.name Git - dotfiles.git/commitdiff
.shellrc: Refactor `cdremote`: Use `_list_remotes`
authorOleg Broytman <phd@phdru.name>
Mon, 5 Aug 2019 16:14:54 +0000 (19:14 +0300)
committerOleg Broytman <phd@phdru.name>
Mon, 5 Aug 2019 16:14:54 +0000 (19:14 +0300)
.shellrc

index 3eeb62129e715602183429a0d902a538828d7a19..112fa4422eb59ef2c2c7f4d1358bf4aa66c7b382 100644 (file)
--- a/.shellrc
+++ b/.shellrc
@@ -225,17 +225,13 @@ if test -x /usr/bin/git >/dev/null 2>&1; then
          cdgitpath remote.$remote.url
       else
 
-         local remote
-         local -a GIT_REMOTES=()
-         for remote in `git remote`; do
-            if git config --get remote.$remote.url | grep -q '^\(/\|\.\./\)'; then
-               GIT_REMOTES+=($remote)
-            fi
-         done
+         _list_remotes '^\(/\|\.\./\)' # (/ or ../ at the beginning)
          if [ ${#GIT_REMOTES[*]} -eq 1 ]; then
             remote=${GIT_REMOTES[0]}
+            unset GIT_REMOTES
             cdgitpath remote.$remote.url
          else
+            unset GIT_REMOTES
             echo "Cannot find directory for any remote" >&2
             echo "Usage: cdremote [remote_name]" >&2
             return 1