Add the git root command

Add the `git root` command shown by Greg in his YouTube video:

https://www.youtube.com/watch?v=C5aRtq-Rtbg
This commit is contained in:
Oliver Davies 2024-05-09 23:57:05 +01:00
parent 5d3f7ef58f
commit 0a5815c116

View file

@ -58,6 +58,22 @@
t "''${repo_path}"
}
git() {
if [[ "''${1}" == "root" ]]; then
shift
local ROOT="$(${pkgs.git}/bin/git rev-parse --show-toplevel 2> /dev/null || echo -n .)"
if [[ $# == 0 ]]; then
cd "''${ROOT}"
else
(cd "''${ROOT}" && eval "''${@}")
fi
else
${pkgs.git}/bin/git "''${@}"
fi
}
just() {
if [[ -f .ignored/justfile ]]; then
${pkgs.just}/bin/just --justfile .ignored/justfile "''${@}"
@ -277,7 +293,6 @@
tags = [ "from:oh-my-zsh" ];
}
{ name = "joshskidmore/zsh-fzf-history-search"; }
{ name = "mollifier/cd-gitroot"; }
{ name = "zsh-users/zsh-completions"; }
{ name = "zsh-users/zsh-syntax-highlighting"; }
];