1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-10-16 11:40:46 +00:00

Compare commits

...

7 commits

Author SHA1 Message Date
Adam Šír
3e62c1eab0
Merge 1b4703387d into 367e9381df 2024-09-23 17:33:04 +02:00
Carlo Sala
367e9381df
chore(git): fix typo 2024-09-23 17:32:44 +02:00
dependabot[bot]
f11cc8fea1
chore(deps): bump idna in /.github/workflows/dependencies (#12688)
Bumps [idna](https://github.com/kjd/idna) from 3.9 to 3.10.
- [Release notes](https://github.com/kjd/idna/releases)
- [Changelog](https://github.com/kjd/idna/blob/master/HISTORY.rst)
- [Commits](https://github.com/kjd/idna/compare/v3.9...v3.10)

---
updated-dependencies:
- dependency-name: idna
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-09-22 16:20:33 +02:00
Adam Šír
1b4703387d
Merge branch 'ohmyzsh:master' into adamsir/git-checkout-interactive 2024-05-09 12:07:54 +02:00
Adam Šír
2cf9ad072d
Update plugins/git-checkout-interactive/README.md
Co-authored-by: Olivia (Zoe) <zoe.i2k1@gmail.com>
2024-05-09 12:07:06 +02:00
Adam Sir
7ab8271cd9
limit output to 10 last branches; configurable 2024-02-28 11:28:36 +01:00
Adam Sir
09976595be
feat(plugin): git checkout interactive 2023-11-01 12:37:17 +01:00
4 changed files with 74 additions and 2 deletions

View file

@ -1,6 +1,6 @@
certifi==2024.8.30
charset-normalizer==3.3.2
idna==3.9
idna==3.10
PyYAML==6.0.2
requests==2.32.3
semver==3.0.2

View file

@ -163,7 +163,7 @@ function git_current_branch() {
}
# Outputs the name of the previously checked out branch
# Usage example: git pull origin $(git_current_branch)
# Usage example: git pull origin $(git_previous_branch)
# rev-parse --symbolic-full-name @{-1} only prints if it is a branch
function git_previous_branch() {
local ref

View file

@ -0,0 +1,15 @@
# lol
This plugin adds a command that lets you interactively switch between branches.
To use it, add `git-checkout-interactive` to the plugins array in your `.zshrc` file:
```zsh
plugins=(... git-checkout-interactive)
```
## Usage Examples
```sh
gci
```

View file

@ -0,0 +1,57 @@
#######################################
# git checkout interactive #
#######################################
function git-checkout-interactive() {
local ITEMS_TO_SHOW=10
# Get all branches sorted by committer date, along with their last commit hash
local branches
branches=$(git for-each-ref --count="$ITEMS_TO_SHOW" --sort=-committerdate --format='%(refname:short) %(objectname:short)' refs/heads/)
# Parse branches
local branch_list=()
local current_branch
current_branch=$(git rev-parse --abbrev-ref HEAD)
if [[ "$current_branch" == "" ]]; then
return 0
fi
while read -r branch hash; do
if [[ "$branch" == "$current_branch" ]]; then
echo "On branch $branch \n"
else
branch_list+=("$branch ($hash)")
fi
done <<< "$branches"
if (( ${#branch_list} == 0 )); then
echo "No other branches available."
return 0
else
echo "Select a branch to switch to:\n"
fi
# Display menu
local i=1
for branch in "${branch_list[@]}"; do
echo "($i) $branch"
((i++))
done
echo -n "\nPlease enter your choice: "
# Handle user input
while :; do
local choice
read -r choice
if (( choice > 0 && choice <= ${#branch_list[@]} )); then
local selected_branch="${branch_list[$((choice))]}"
local target_branch="${selected_branch//->}"
target_branch="${target_branch%% *}"
git checkout "$target_branch"
break
else
break
fi
done
}
alias gci="git-checkout-interactive || return 0"