]> git.phdru.name Git - dotfiles.git/commitdiff
.bashrc, .shellrc: Move `cdgitpath`
authorOleg Broytman <phd@phdru.name>
Sun, 15 Oct 2023 12:22:44 +0000 (15:22 +0300)
committerOleg Broytman <phd@phdru.name>
Sun, 15 Oct 2023 12:47:59 +0000 (15:47 +0300)
It doesn't contain any bash-related funcionality.

.bashrc
.shellrc

diff --git a/.bashrc b/.bashrc
index ef3423fc6ac7a262add2802dc18179e36ea9fbc8..85cb4d87d8dbe099264af8d6b323b72131fb6576 100644 (file)
--- a/.bashrc
+++ b/.bashrc
@@ -196,26 +196,6 @@ trap '[ "$VIRTUAL_ENV" ] && deactivate' EXIT
 
 
 if test -x /usr/bin/git >/dev/null 2>&1; then
-    # chdir to a directory
-    cdgitpath() {
-        if [ $# -ne 1 ]; then
-            echo "Usage: cdgitpath path_key" >&2
-            return 1
-        fi
-
-        path_key="$1"
-        if [ -z "$path_key" ]; then
-            echo "Usage: cdgitpath path_key" >&2
-            return 1
-        fi
-
-        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)
     cdremote() {
         if [ $# -gt 1 ]; then
index 78beaf7ad6991ee6e20a79304de731d21dc89dae..b06ba8b24312a12021ba31d788e50cf0e5fcfbb3 100644 (file)
--- a/.shellrc
+++ b/.shellrc
@@ -52,6 +52,28 @@ if [ -n "$STY" -a "$WINDOW" != 0 ]; then
     unset MAILCHECK
 fi
 
+if test -x /usr/bin/git >/dev/null 2>&1; then
+    # chdir to a directory
+    cdgitpath() {
+        if [ $# -ne 1 ]; then
+            echo "Usage: cdgitpath path_key" >&2
+            return 1
+        fi
+
+        path_key="$1"
+        if [ -z "$path_key" ]; then
+            echo "Usage: cdgitpath path_key" >&2
+            return 1
+        fi
+
+        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"
+    }
+fi
+
 include() {
     cfg="$1"
     shift