diff options
| author | srdusr <trevorgray@srdusr.com> | 2023-04-07 09:16:30 +0200 |
|---|---|---|
| committer | srdusr <trevorgray@srdusr.com> | 2023-04-07 09:16:30 +0200 |
| commit | 553e830c02015b7cf928243a68de504db135a3bb (patch) | |
| tree | 2ff53b6801faaa3f5d9368b3b9089f01bf944bdb /.config/zsh | |
| parent | 444645f1b2a1b3d79f87e14b85fc527b12b23e93 (diff) | |
| download | dotfiles-553e830c02015b7cf928243a68de504db135a3bb.tar.gz dotfiles-553e830c02015b7cf928243a68de504db135a3bb.zip | |
New alias and function to make sure we can see changes and use git tooling for dotfiles
Diffstat (limited to '.config/zsh')
| -rw-r--r-- | .config/zsh/.zshrc | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index 60305c6..912a51c 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -366,8 +366,39 @@ extract () { fi } -# Dotfiles -alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME' + +### Dotfiles +# Set up the dotfiles repository and alias +alias config='git --git-dir=$HOME/.cfg --work-tree=$HOME' + +# Function to set up Git environment variables +function set_git_env() { + local cwd="$PWD" + while [[ "$cwd" != "/" ]]; do + if [[ -d "$cwd/.git" ]]; then + unset GIT_DIR + unset GIT_WORK_TREE + return + fi + cwd=$(dirname "$cwd") + done + export GIT_DIR="$HOME/.cfg" + export GIT_WORK_TREE="$HOME" +} + +# Set up Git environment variables on initial shell startup +set_git_env + +# Function to set up Git environment variables whenever you execute a command +function preexec() { + set_git_env +} + +# Enable the preexec function +autoload -Uz add-zsh-hook +add-zsh-hook preexec preexec + + #alias cfg='config subtree pull --prefx' #alias gsp="git subtree push --prefix=_site git@github.com:mertnuhoglu/blog_datascience.git" #alias gsp="git subtree push.local/bin/scripts https://github.com/srdusr/scripts.git main --squash @@ -404,9 +435,9 @@ function gsp config subtree pull --prefix=$PREFIX $REMOTE $BRANCH done } + alias vi='nvim' alias nv='nvim' -alias trash="gio trash" alias trash_restore='gio trash --restore "$(gio trash --list | fzf | cut -f 1)"' alias ec='$EDITOR $HOME/.config/zsh/.zshrc' alias sc="source $HOME/.config/zsh/.zshrc" |
