]> git.phdru.name Git - dotfiles.git/blobdiff - .shellrc
Feat(recode-filenames-recursive): Allow to omit parameters
[dotfiles.git] / .shellrc
index b06ba8b24312a12021ba31d788e50cf0e5fcfbb3..9f9242ae5e6a4d3d05448af6f06ceb2be68a222d 100644 (file)
--- a/.shellrc
+++ b/.shellrc
@@ -72,6 +72,22 @@ if test -x /usr/bin/git >/dev/null 2>&1; then
         fi
         cd "$path_url"
     }
+
+    # See https://stackoverflow.com/a/77266926/7976758
+
+    cd_worktree() {
+        if [ $# -ne 1 ]; then
+            echo "Usage: cd_worktree <branch>" >&2
+            return 1
+        fi
+        path="$(git worktree list | grep -F "$1" | awk '{print $1}')"
+        if [ -n "$path" ]; then
+            cd "$path"
+        else
+            echo "Cannot find path for branch '$1'" >&2
+            return 1
+        fi
+    }
 fi
 
 include() {
@@ -147,7 +163,7 @@ mc() {
         rc=1
     fi
 
-    unset MC_FOUND MC_PWD_FILE MC_SLOW MC_TMP_DIR MC_XTERM
+    unset wrapper MC_FOUND MC_PWD_FILE MC_SLOW MC_TMP_DIR MC_XTERM
 
     return $rc
 }