From d16290e59177c73d7f41eca832b30ee49656d2c0 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Thu, 15 Aug 2019 22:12:56 +0300 Subject: [PATCH] Feat(.shellrc): Allow `file:/` URLs for `cdgitpath` and `cdremote` --- .shellrc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.shellrc b/.shellrc index d9c4bad..edb29b8 100644 --- a/.shellrc +++ b/.shellrc @@ -199,7 +199,11 @@ if test -x /usr/bin/git >/dev/null 2>&1; then return 1 fi - cd "`git config --get --path $path_key`" + path_url="`git config --get --path $path_key`" + if echo "$path_url" | grep -q '^file:/'; then + path_url="`echo \"$path_url\" | sed 's@^file:/\+@/@'`" + fi + cd "$path_url" } # chdir to a remote's directory (if the remote is on the local FS) @@ -222,7 +226,7 @@ if test -x /usr/bin/git >/dev/null 2>&1; then return 1 fi - if git config --get remote.$remote.url | grep -q '^\(/\|\.\./\)'; then + if git config --get remote.$remote.url | grep -q '^\(file:/\|/\|\.\./\)'; then cdgitpath remote.$remote.url else @@ -232,7 +236,7 @@ if test -x /usr/bin/git >/dev/null 2>&1; then return 1 fi - _list_remotes '^\(/\|\.\./\)' # (/ or ../ at the beginning) + _list_remotes '^\(file:/\|/\|\.\./\)' # (file:/ or / or ../ at the beginning) if [ ${#GIT_REMOTES[*]} -eq 1 ]; then remote=${GIT_REMOTES[0]} unset GIT_REMOTES @@ -295,7 +299,7 @@ if test -x /usr/bin/git >/dev/null 2>&1; then # completion for cdremote - list remotes with directories as URLs _cdremote_complete() { - _list_remotes_completion '^\(/\|\.\./\)' # (/ or ../ at the beginning) + _list_remotes_completion '^\(file:/\|/\|\.\./\)' # (file:/ or / or ../ at the beginning) if [ ${#COMPREPLY[*]} -eq 0 ]; then _list_remotes_completion . fi -- 2.39.2