aboutsummaryrefslogtreecommitdiff
path: root/.config
diff options
context:
space:
mode:
Diffstat (limited to '.config')
-rw-r--r--.config/zsh/.zshrc22
1 files changed, 11 insertions, 11 deletions
diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc
index 159f079..f6ad077 100644
--- a/.config/zsh/.zshrc
+++ b/.config/zsh/.zshrc
@@ -373,7 +373,7 @@ extract () {
### Dotfiles
alias config='git --git-dir=$HOME/.cfg --work-tree=$HOME'
-## Set bare dotfiles repository git environment variables dynamically
+# Set bare dotfiles repository git environment variables dynamically
function set_git_env_vars() {
# Check if the current command is a package manager command
if [[ "${(%)${(z)history[1]}}" =~ ^(pacman|yay|apt|dnf|brew|npm|pip|gem|go|cargo) ]]; then
@@ -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
- 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
+ export GIT_DIR="$HOME/.cfg"
+ export GIT_WORK_TREE=$(realpath $(eval echo ~))
else
unset GIT_DIR
unset GIT_WORK_TREE
fi
else
- export GIT_DIR="$HOME/.cfg"
- export GIT_WORK_TREE=$(realpath $(eval echo ~))
+ 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
fi
}