diff --git a/git-recent b/git-recent index 1080931..97ab978 100755 --- a/git-recent +++ b/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" } diff --git a/homebrew/git-recent.rb b/homebrew/git-recent.rb index d6b1684..c1e1f11 100644 --- a/homebrew/git-recent.rb +++ b/homebrew/git-recent.rb @@ -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