mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-20 03:02:29 +01:00
Check if there is a git repository dir.
This commit is contained in:
parent
a8ef111a79
commit
eb0fed5cd6
1 changed files with 14 additions and 8 deletions
|
|
@ -125,17 +125,23 @@ alias gsd='git svn dcommit'
|
|||
# Usage example: git pull origin $(current_branch)
|
||||
#
|
||||
function current_branch() {
|
||||
if [ ! -d .git ]; then return; fi
|
||||
ref=$(git symbolic-ref HEAD 2> /dev/null) || \
|
||||
ref=$(git rev-parse --short HEAD 2> /dev/null) || return
|
||||
echo ${ref#refs/heads/}
|
||||
if [ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1; then
|
||||
ref=$(git symbolic-ref HEAD 2> /dev/null) || \
|
||||
ref=$(git rev-parse --short HEAD 2> /dev/null) || return
|
||||
echo ${ref#refs/heads/};
|
||||
else
|
||||
return;
|
||||
fi
|
||||
}
|
||||
|
||||
function current_repository() {
|
||||
if [ ! -d .git ]; then return; fi
|
||||
ref=$(git symbolic-ref HEAD 2> /dev/null) || \
|
||||
ref=$(git rev-parse --short HEAD 2> /dev/null) || return
|
||||
echo $(git remote -v | cut -d':' -f 2)
|
||||
if [ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1; then
|
||||
ref=$(git symbolic-ref HEAD 2> /dev/null) || \
|
||||
ref=$(git rev-parse --short HEAD 2> /dev/null) || return
|
||||
echo $(git remote -v | cut -d':' -f 2);
|
||||
else
|
||||
return;
|
||||
fi
|
||||
}
|
||||
|
||||
# these aliases take advantage of the previous function
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue