mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-12-18 10:22:00 +00:00
lib: add git function to determine repository name (#4989)
Closes #4989 Co-authored-by: Marc Cornellà <marc.cornella@live.com>
This commit is contained in:
parent
22cf7159ec
commit
1c300d3a76
1 changed files with 9 additions and 0 deletions
|
@ -199,3 +199,12 @@ function git_current_user_name() {
|
||||||
function git_current_user_email() {
|
function git_current_user_email() {
|
||||||
command git config user.email 2>/dev/null
|
command git config user.email 2>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Output the name of the root directory of the git repository
|
||||||
|
# Usage example: $(git_repo_name)
|
||||||
|
function git_repo_name() {
|
||||||
|
local repo_path
|
||||||
|
if repo_path="$(git rev-parse --show-toplevel 2>/dev/null)" && [[ -n "$repo_path" ]]; then
|
||||||
|
echo ${repo_path:t}
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue