Skip to content

aliases: Add new git-omz alias file #1831

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions aliases/available/git-omz.aliases.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# shellcheck shell=bash
cite 'about-alias'
about-alias 'git aliases from oh-my-zsh (incompatible with regular git aliases option)'

if _bash-it-component-item-is-enabled aliases git; then
_log_warning "git-omz aliases are incompatible with regular git aliases"
return 1
fi

# Load after regular git aliases
# BASH_IT_LOAD_PRIORITY: 160

# Setup git version
read -ra git_version_arr <<< "$(git version 2> /dev/null)"
git_version="${git_version_arr[2]}"

# Setup is-at-least
function is-at-least {
local expected_version=$1
local actual_version=$2
local versions

printf -v versions '%s\n%s' "$expected_version" "$actual_version"
[[ $versions = "$(sort -V <<< "$versions")" ]]
}

# Setup git_current_branch
function git_current_branch {
_git-branch
}

# shellcheck disable=SC1090
source "${BASH_IT}"/vendor/github.com/ohmyzsh/ohmyzsh/plugins/git/git.plugin.zsh
6 changes: 6 additions & 0 deletions aliases/available/git.aliases.bash
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# shellcheck shell=bash
about-alias 'common git abbreviations'

# We can use this variable to make sure that we don't accidentally clash with git-zsh aliases
if _bash-it-component-item-is-enabled aliases git-omz; then
_log_warning "The aliases from 'git' and from 'git-omz' conflict with each other; please only enable one."
return 1
fi

alias g='git'
alias get='git'
alias got='git '
Expand Down
31 changes: 20 additions & 11 deletions test/lib/search.bats
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,26 @@ function local_setup() {
}

@test "search: git" {
local plugin completion
run _bash-it-search 'git' --no-color
assert_success
assert_line -n 0 ' aliases: git gitsvn '
assert_line -n 1 -p ' plugins:'
for plugin in "autojump" "git" "gitstatus" "git-subrepo" "jgitflow" "jump"; do
assert_line -n 1 -p "$plugin"
done
for completion in "git" "git_flow" "git_flow_avh" "github-cli"; do
assert_line -n 2 -p "$completion"
done
local plugin completion
run _bash-it-search 'git' --no-color

assert_line -n 0 -p ' aliases:'
assert_success
for alias in 'git' 'gitsvn' 'git-omz'
do
echo $alias
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't the echo defeat the test?

assert_line -n 0 -p $alias
done

assert_line -n 1 -p ' plugins:'
for plugin in "autojump" "git" "gitstatus" "git-subrepo" "jgitflow" "jump"
do
assert_line -n 1 -p "$plugin"
done
for completion in "git" "git_flow" "git_flow_avh" "github-cli"
do
assert_line -n 2 -p "$completion"
done
}

@test "search: ruby gem bundle rake rails" {
Expand Down
21 changes: 21 additions & 0 deletions vendor/github.com/ohmyzsh/ohmyzsh/LICENSE.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading