Skip to content

Commit

Permalink
feat: Add function for switching to current git root dir
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpovel committed Aug 29, 2023
1 parent 6fe15dc commit 3eacf44
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions home/.zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,22 @@ plugins=(

export ZSH_COLORIZE_STYLE="dracula"

# =====================================================================================
# Custom functions
# =====================================================================================

# Switches to current git repository's root directory, if possible.
function rr() {
dir="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"

if command -v z 1>/dev/null 2>&1; then
# Use zoxide if available
__zoxide_z "$dir"
else
cd "$dir"
fi
}

# =====================================================================================
# Custom aliases
# =====================================================================================
Expand Down

0 comments on commit 3eacf44

Please sign in to comment.