twig root¶
Print the root directory of the current git repository.
Usage¶
Description¶
Prints the absolute path to the root of the current git repository — the directory containing .git. Useful for scripting or jumping to the repo root in your shell.
Shell integration¶
To make twig root change your current directory (not just print it), add this function to your .zshrc or .bashrc:
This is necessary because a subprocess cannot change the parent shell's working directory — the function wrapper handles that.
Examples¶
Note
Running twig root outside a git repository exits with a non-zero status and prints an error. This makes it safe to use in scripts that need to guard against non-repo directories.