Skip to content

Commit 863f8e2

Browse files
authored
Merge pull request #1831 from NoahGorny/add-git-zsh-aliases
2 parents 0743ebe + 4142b62 commit 863f8e2

File tree

6 files changed

+637
-11
lines changed

6 files changed

+637
-11
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# shellcheck shell=bash
2+
cite 'about-alias'
3+
about-alias 'git aliases from oh-my-zsh (incompatible with regular git aliases option)'
4+
5+
if _bash-it-component-item-is-enabled aliases git; then
6+
_log_warning "git-omz aliases are incompatible with regular git aliases"
7+
return 1
8+
fi
9+
10+
# Load after regular git aliases
11+
# BASH_IT_LOAD_PRIORITY: 160
12+
13+
# Setup git version
14+
read -ra git_version_arr <<< "$(git version 2> /dev/null)"
15+
git_version="${git_version_arr[2]}"
16+
17+
# Setup is-at-least
18+
function is-at-least {
19+
local expected_version=$1
20+
local actual_version=$2
21+
local versions
22+
23+
printf -v versions '%s\n%s' "$expected_version" "$actual_version"
24+
[[ $versions = "$(sort -V <<< "$versions")" ]]
25+
}
26+
27+
# Setup git_current_branch
28+
function git_current_branch {
29+
_git-branch
30+
}
31+
32+
# shellcheck disable=SC1090
33+
source "${BASH_IT}"/vendor/github.com/ohmyzsh/ohmyzsh/plugins/git/git.plugin.zsh

aliases/available/git.aliases.bash

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# shellcheck shell=bash
22
about-alias 'common git abbreviations'
33

4+
# We can use this variable to make sure that we don't accidentally clash with git-zsh aliases
5+
if _bash-it-component-item-is-enabled aliases git-omz; then
6+
_log_warning "The aliases from 'git' and from 'git-omz' conflict with each other; please only enable one."
7+
return 1
8+
fi
9+
410
alias g='git'
511
alias get='git'
612
alias got='git '

test/lib/search.bats

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,26 @@ function local_setup() {
1818
}
1919

2020
@test "search: git" {
21-
local plugin completion
22-
run _bash-it-search 'git' --no-color
23-
assert_success
24-
assert_line -n 0 ' aliases: git gitsvn '
25-
assert_line -n 1 -p ' plugins:'
26-
for plugin in "autojump" "git" "gitstatus" "git-subrepo" "jgitflow" "jump"; do
27-
assert_line -n 1 -p "$plugin"
28-
done
29-
for completion in "git" "git_flow" "git_flow_avh" "github-cli"; do
30-
assert_line -n 2 -p "$completion"
31-
done
21+
local plugin completion
22+
run _bash-it-search 'git' --no-color
23+
24+
assert_line -n 0 -p ' aliases:'
25+
assert_success
26+
for alias in 'git' 'gitsvn' 'git-omz'
27+
do
28+
echo $alias
29+
assert_line -n 0 -p $alias
30+
done
31+
32+
assert_line -n 1 -p ' plugins:'
33+
for plugin in "autojump" "git" "gitstatus" "git-subrepo" "jgitflow" "jump"
34+
do
35+
assert_line -n 1 -p "$plugin"
36+
done
37+
for completion in "git" "git_flow" "git_flow_avh" "github-cli"
38+
do
39+
assert_line -n 2 -p "$completion"
40+
done
3241
}
3342

3443
@test "search: ruby gem bundle rake rails" {

vendor/github.com/ohmyzsh/ohmyzsh/LICENSE.txt

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)