mirror of
https://github.com/paulirish/git-recent.git
synced 2026-09-10 07:26:16 -04:00
ctrl-y to copy branch name to clipboard
This commit is contained in:
parent
6bd7ff3fdf
commit
d26db02f7c
16
git-recent
16
git-recent
|
|
@ -41,6 +41,19 @@ elif command -v diff-so-fancy >/dev/null 2>&1; then
|
|||
diffbranch_cmd="$diffbranch_cmd | diff-so-fancy"
|
||||
fi
|
||||
|
||||
# Copy to clipboard, variants for mac/linux
|
||||
copy_cmd="echo 'Could not copy {} to clipboard.'"
|
||||
if command -v pbcopy >/dev/null; then
|
||||
copy_cmd="printf '%s' {} | pbcopy"
|
||||
elif command -v wl-copy >/dev/null; then
|
||||
copy_cmd="printf '%s' {} | wl-copy"
|
||||
elif command -v xclip >/dev/null; then
|
||||
copy_cmd="printf '%s' {} | xclip -selection clipboard"
|
||||
elif command -v xsel >/dev/null; then
|
||||
copy_cmd="printf '%s' {} | xsel --clipboard"
|
||||
fi
|
||||
|
||||
|
||||
# fzf git inspiration:
|
||||
# - https://github.com/junegunn/fzf/wiki/Examples#git
|
||||
# - https://github.com/junegunn/fzf/wiki/Examples-(fish)#git
|
||||
|
|
@ -53,9 +66,10 @@ _browse_branches() {
|
|||
--border-label-pos=2 --border-label '🌲 Branches' --border \
|
||||
--no-hscroll --no-multi \
|
||||
--preview-window='right,70%,border-left,border-rounded' --preview="$uniqcommits_cmd" --preview-label="Commits unique to branch" \
|
||||
--header $'ENTER (checkout)\nCTRL-O (show branch diff)\n' \
|
||||
--header $'ENTER (checkout)\nCTRL-O (show branch diff)\nCTRL-Y (copy name to clipboard)' \
|
||||
--bind 'preview-scroll-up:preview-up+preview-up+preview-up' \
|
||||
--bind 'preview-scroll-down:preview-down+preview-down+preview-down' \
|
||||
--bind "ctrl-y:execute-silent($copy_cmd)" \
|
||||
--bind "ctrl-o:preview:$diffbranch_cmd"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class GitRecent < Formula
|
|||
sha256 cellar: :any_skip_relocation, all: "3a4143920243a863447daa6f2b17b3cda4e0a163e8502c6c36a910eee4ee7450"
|
||||
end
|
||||
|
||||
# depends_on "fzf"
|
||||
depends_on "fzf"
|
||||
|
||||
depends_on macos: :sierra
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue