Skip to content

Commit

Permalink
refactor: rename worktree_jump to worktree_select
Browse files Browse the repository at this point in the history
  • Loading branch information
suft committed Nov 17, 2024
1 parent a339901 commit 2603418
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ forgit_cherry_pick=gcp
forgit_rebase=grb
forgit_blame=gbl
forgit_fixup=gfu
forgit_worktree_jump=gwj
forgit_worktree_select=gws
forgit_worktree_lock=gwl
forgit_worktree_remove=gwr
forgit_worktree_unlock=gwu
Expand Down Expand Up @@ -316,7 +316,7 @@ Customizing fzf options for each command individually is also supported:
| `gbl` | `FORGIT_BLAME_FZF_OPTS` |
| `gfu` | `FORGIT_FIXUP_FZF_OPTS` |
| `gcp` | `FORGIT_CHERRY_PICK_FZF_OPTS` |
| `gwj` | `FORGIT_WORKTREE_JUMP_FZF_OPTS` |
| `gws` | `FORGIT_WORKTREE_SELECT_FZF_OPTS` |
| `gwl` | `FORGIT_WORKTREE_LOCK_FZF_OPTS` |
| `gwr` | `FORGIT_WORKTREE_REMOVE_FZF_OPTS` |
| `gwu` | `FORGIT_WORKTREE_UNLOCK_FZF_OPTS` |
Expand Down
6 changes: 3 additions & 3 deletions bin/git-forgit
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,7 @@ _forgit_worktree_preview() {
git log "$sha" "${_forgit_log_preview_options[@]}" --
}

_forgit_worktree_jump() {
_forgit_worktree_select() {
_forgit_inside_work_tree || _forgit_inside_git_dir || return 1
local worktree_list count tree opts
worktree_list=$(git worktree list | grep -vE "prunable$" | awk '{print $1}' | _forgit_filter_existing_paths)
Expand All @@ -1034,7 +1034,7 @@ _forgit_worktree_jump() {
$FORGIT_FZF_DEFAULT_OPTS
+s +m --tiebreak=index
--preview=\"$FORGIT worktree_preview {1}\"
$FORGIT_WORKTREE_JUMP_FZF_OPTS
$FORGIT_WORKTREE_SELECT_FZF_OPTS
"

tree=$(echo "$worktree_list" | FZF_DEFAULT_OPTS="$opts" fzf)
Expand Down Expand Up @@ -1146,7 +1146,7 @@ public_commands=(
"revert_commit"
"stash_show"
"stash_push"
"worktree_jump"
"worktree_select"
"worktree_lock"
"worktree_remove"
"worktree_unlock"
Expand Down
3 changes: 2 additions & 1 deletion conf.d/forgit.plugin.fish
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ if test -z "$FORGIT_NO_ALIASES"
abbr -a -- (string collect $forgit_revert_commit; or string collect "grc") git-forgit revert_commit
abbr -a -- (string collect $forgit_blame; or string collect "gbl") git-forgit blame
abbr -a -- (string collect $forgit_checkout_tag; or string collect "gct") git-forgit checkout_tag
abbr -a -- (string collect $forgit_worktree_jump; or string collect "gwj") 'set tree (git-forgit worktree_jump); test -n "$tree"; and cd "$tree"'
abbr -a -- (string collect $forgit_worktree_select; or string collect "gwj") git-forgit worktree_select
abbr -a -- (string collect $forgit_worktree_jump; or string collect "gwj") 'set tree (git-forgit worktree_select); test -n "$tree"; and cd "$tree"'
abbr -a -- (string collect $forgit_worktree_lock; or string collect "gwl") git-forgit worktree_lock
abbr -a -- (string collect $forgit_worktree_remove; or string collect "gwr") git-forgit worktree_remove
abbr -a -- (string collect $forgit_worktree_unlock; or string collect "gwu") git-forgit worktree_unlock
Expand Down
8 changes: 7 additions & 1 deletion forgit.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,12 @@ forgit::ignore::clean() {
"$FORGIT" ignore_clean "$@"
}

forgit::worktree::select() {
"$FORGIT" worktree_select "$@"
}

forgit::worktree::jump() {
cd "$("$FORGIT" worktree_jump "$@")" || exit
cd "$(forgit::worktree::select "$@")" || exit
}

forgit::worktree::lock() {
Expand Down Expand Up @@ -176,6 +180,7 @@ if [[ -z "$FORGIT_NO_ALIASES" ]]; then
export forgit_rebase="${forgit_rebase:-grb}"
export forgit_fixup="${forgit_fixup:-gfu}"
export forgit_blame="${forgit_blame:-gbl}"
export forgit_worktree_select="${forgit_worktree_select:-gws}"
export forgit_worktree_jump="${forgit_worktree_jump:-gwj}"
export forgit_worktree_lock="${forgit_worktree_lock:-gwl}"
export forgit_worktree_remove="${forgit_worktree_remove:-gwr}"
Expand All @@ -200,6 +205,7 @@ if [[ -z "$FORGIT_NO_ALIASES" ]]; then
alias "${forgit_rebase}"='forgit::rebase'
alias "${forgit_fixup}"='forgit::fixup'
alias "${forgit_blame}"='forgit::blame'
alias "${forgit_worktree_select}"='forgit::worktree::select'
alias "${forgit_worktree_jump}"='forgit::worktree::jump'
alias "${forgit_worktree_lock}"='forgit::worktree::lock'
alias "${forgit_worktree_remove}"='forgit::worktree::remove'
Expand Down

0 comments on commit 2603418

Please sign in to comment.