diff --git a/.gitconfig b/.gitconfig index c4f38c9..07dcd52 100644 --- a/.gitconfig +++ b/.gitconfig @@ -70,6 +70,7 @@ up = pull --rebase --autostash rebaseour = "rebase -Xours" rank = "shortlog -s -n --no-merges" + root = rev-parse --show-toplevel [rebase] # when rebasing, update the other common branch too. # See https://andrewlock.net/working-with-stacked-branches-in-git-is-easier-with-update-refs/ diff --git a/.zsh/30_alias.zsh b/.zsh/30_alias.zsh index a1c0dbf..e3de0cc 100644 --- a/.zsh/30_alias.zsh +++ b/.zsh/30_alias.zsh @@ -65,3 +65,9 @@ alias -g S='&> /dev/null &' alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' alias senv='source ~/venv/bin/activate' +alias r='if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) != 'true' ]]; then + >&2 echo "Not a git repository" + return 1 +else + cd $(git root) +fi'