aboutsummaryrefslogtreecommitdiff
path: root/.config
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2024-05-16 19:44:06 +0200
committersrdusr <trevorgray@srdusr.com>2024-05-16 19:44:06 +0200
commitb7a10387839ccdeb725ea152ebe0ab60580b1745 (patch)
tree77c2dfe91440cd966d304fc2357e83c33ddc5fe8 /.config
parentd4b035c32a6ad4a28bb971f7bb79c2f6923432a7 (diff)
downloaddotfiles-b7a10387839ccdeb725ea152ebe0ab60580b1745.tar.gz
dotfiles-b7a10387839ccdeb725ea152ebe0ab60580b1745.zip
Testing install.sh
Diffstat (limited to '.config')
-rw-r--r--.config/zsh/user/functions.zsh24
1 files changed, 19 insertions, 5 deletions
diff --git a/.config/zsh/user/functions.zsh b/.config/zsh/user/functions.zsh
index bf8242f..1928cd5 100644
--- a/.config/zsh/user/functions.zsh
+++ b/.config/zsh/user/functions.zsh
@@ -1,12 +1,26 @@
# Function to temporarily unset GIT_WORK_TREE
function git_without_work_tree() {
- GIT_WORK_TREE_OLD="$GIT_WORK_TREE"
- unset GIT_WORK_TREE
- "$@"
- export GIT_WORK_TREE="$GIT_WORK_TREE_OLD"
+ # Check if the current directory is a Git repository
+ if [ -d "$PWD/.git" ]; then
+ # Check if the current directory is inside the work tree
+ if [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]; then
+ # If it's a Git repository and inside the work tree, proceed with unsetting GIT_WORK_TREE
+ GIT_WORK_TREE_OLD="$GIT_WORK_TREE"
+ unset GIT_WORK_TREE
+ "$@"
+ export GIT_WORK_TREE="$GIT_WORK_TREE_OLD"
+ else
+ # If it's a Git repository but not inside the work tree, call git command directly
+ git "$@"
+ fi
+ else
+ # If it's not a Git repository, call git command directly
+ git "$@"
+ fi
}
-alias git='git_without_work_tree git'
+# Set alias conditionally
+alias git='git_without_work_tree'
# Set bare dotfiles repository git environment variables dynamically
function set_git_env_vars() {