Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Ohmyzsh
Commits
1c300d3a
Commit
1c300d3a
authored
Apr 10, 2016
by
Evan Chiu
Committed by
Marc Cornellà
Feb 10, 2020
Browse files
lib: add git function to determine repository name (#4989)
Closes #4989 Co-authored-by:
Marc Cornellà
<
marc.cornella@live.com
>
parent
22cf7159
Changes
1
Show whitespace changes
Inline
Side-by-side
lib/git.zsh
View file @
1c300d3a
...
@@ -199,3 +199,12 @@ function git_current_user_name() {
...
@@ -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
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment