diff options
Diffstat (limited to '.config/zsh/.zshrc')
| -rw-r--r-- | .config/zsh/.zshrc | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index 883d31c..159f079 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -383,21 +383,21 @@ function set_git_env_vars() { if [[ -n "$git_dir" ]]; then local is_bare="$(git -C "$git_dir" rev-parse --is-bare-repository 2>/dev/null)" if [[ "$is_bare" == "true" ]]; then - export GIT_DIR="$HOME/.cfg" - export GIT_WORK_TREE=$(realpath $(eval echo ~)) + local root_dir="$(git rev-parse --show-toplevel 2>/dev/null)" + if [[ "$root_dir" == "$(realpath $(eval echo ~))" ]]; then + unset GIT_DIR + unset GIT_WORK_TREE + else + export GIT_DIR="$HOME/.cfg" + export GIT_WORK_TREE=$(realpath $(eval echo ~)) + fi else unset GIT_DIR unset GIT_WORK_TREE fi else - local root_dir="$(git rev-parse --show-toplevel 2>/dev/null)" - if [[ -n "$root_dir" ]]; then - unset GIT_DIR - export GIT_WORK_TREE="$root_dir" - else - export GIT_DIR="$HOME/.cfg" - export GIT_WORK_TREE=$(realpath $(eval echo ~)) - fi + export GIT_DIR="$HOME/.cfg" + export GIT_WORK_TREE=$(realpath $(eval echo ~)) fi } |
