Add copy current git branch name binding
This commit is contained in:
@@ -133,9 +133,9 @@ EOF
|
|||||||
eval build
|
eval build
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Bind C-B to fuzzy find & complete cmake variables.
|
# Bind C-X C-V to fuzzy find & complete cmake variables.
|
||||||
zle -N .build-var
|
zle -N .build-var
|
||||||
bindkey '^B' .build-var
|
bindkey '^X^V' .build-var
|
||||||
}
|
}
|
||||||
|
|
||||||
# Build then run a target residing in `~build/bin`.
|
# Build then run a target residing in `~build/bin`.
|
||||||
|
|||||||
@@ -203,3 +203,18 @@ function .fzf-history-search() {
|
|||||||
}
|
}
|
||||||
zle -N .fzf-history-search
|
zle -N .fzf-history-search
|
||||||
bindkey '^R' .fzf-history-search
|
bindkey '^R' .fzf-history-search
|
||||||
|
|
||||||
|
# Copy the branch name checked out in the current worktree to the clipboard,
|
||||||
|
# falling back to the abbreviated commit when HEAD is detached.
|
||||||
|
function .copy-git-branch() {
|
||||||
|
local branch
|
||||||
|
branch=$(git symbolic-ref --quiet --short HEAD 2>/dev/null) ||
|
||||||
|
branch=$(git rev-parse --short HEAD 2>/dev/null)
|
||||||
|
if [[ -n "$branch" ]]; then
|
||||||
|
print -rn -- "$branch" | copy
|
||||||
|
else
|
||||||
|
zle -M "not a git worktree"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
zle -N .copy-git-branch
|
||||||
|
bindkey -p '^X^B' .copy-git-branch
|
||||||
|
|||||||
Reference in New Issue
Block a user