Debian Codegraph @

plugins/gitroot

raw
1 #!/usr/bin/env sh
2
3 # Description: cd to the top level of the current git repository in the current context
4 # Dependencies: git
5 # Shell: sh
6 # Author: https://github.com/PatrickF1
7
8 root="$(git rev-parse --show-toplevel 2>/dev/null)"
9 if [ -n "$root" ]; then
10 printf "%s" "0c$root" > "$NNN_PIPE"
11 else
12 printf "Not in a git repository"
13 read -r _
14 exit 1
15 fi