23

Can I copy source code in the left-bottom panel in gitk? Any keyboard shortcut or other functions?

OS: Ubuntu 9.04 Desktop / gitk: 1:1.6.0.4-1ubuntu2

Thank you.

sfsn
  • 295
  • 4
  • 7

6 Answers6

10

It should support the (X clipboard style) copy, even though a bug has been reported for that feature on Ubuntu:

gitk supports the normal X clipboard: select to copy, middle-click to paste.

My mouse does not have a middle button and select isn't copying.
It would be immensely useful to have:

  • the copy and paste options available:
    • in the edit menu,
    • or right click menu,
  • or supporting the standard Ctrl+c, Ctrl+v keyboard shortcuts.
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • @sho1: so a simple select is not enough to copy in your case? – VonC Jul 29 '10 at 08:23
  • No. It seems not to work... I guess I should make sure my X clipboard goes well. Thanks. – sfsn Aug 03 '10 at 01:47
  • Selecting text in diffs works for me in Mint 17. (I haven't tried Ctrl+C or Ctrl+V, because those aren't standard—X is not Windows.) Unfortunately, though, file paths and SHAs don't appear to be selectable. – Michael Scheper Sep 23 '16 at 16:40
9

Workaround:

  1. Right-click on the source code you want to copy.
  2. Select "Run git gui blame on this line."

This opens up a new gui blame editor with full copy/paste functionality.

Dan Kanze
  • 18,485
  • 28
  • 81
  • 134
  • 1
    Does not work for me (Windows 7), the text in "git gui" is still not copyable – M.M Aug 21 '15 at 05:49
  • How would the gui blame editor look like? It does not open up for me when I select "Run git gui blame on this line." – Naveen Apr 11 '16 at 15:41
6

I had trouble with this on Ubuntu (with Gnome) as well. However I found I could select text and then use 'xclip -o' to print it to the console (which I could then use/copy as normal). I guess the X clipboard is separate from the normal Gnome clipboard.

Rick Byers
  • 61
  • 1
  • 1
  • 1
    It is. In X, it's called the selection buffer. The 'clipboard' is a GNOME thing, which has some extra features, such as being able to store more than just text, and surviving when the program you're copying from terminates. The selection buffer is quicker, though; it doesn't require the extra keypresses. • It's actually very useful for them to be separate, but unfortunately, a lot of newer software conflates them. • Some OSes have workarounds for mouses missing the middle mouse button, such as simultaneously clicking the left and right button. – Michael Scheper Sep 23 '16 at 16:51
2

Run Gitk in backgroup mode and don't close it while you paste. The clipboard will work better while gitk is still running.

$ gitk &

You can also make it as function in ~/.bashrc or ~/.bash_aliases

function gitk() { 
    /usr/bin/gitk $@ & 
}
Michael
  • 37
  • 1
  • 7
  • 1
    this did not fix the issue of copying from gitk and keep it in the clipboard even after gitk is closed. However I thumbed it up because this fixes another problem for me which is open gitk GUI and keep it open while using the shell in another stuff. Thanks mate. – Mina Luke Nov 01 '16 at 03:32
  • I have found a better way for gitk to run at background. I have been using it ever since. It supports parameters now. – Michael Jun 29 '17 at 23:01
0

I also have exactly the same problem on my Ubuntu 16.04 with gnome desktop. It seems a bug in old version and fixed in latest version. Upgrade gitk with these steps:

git clone git://ozlabs.org/~paulus/gitk
cd gitk
make
sudo copy gitk /usr/bin/gitk
Houcheng
  • 2,674
  • 25
  • 32
0

Q: How copy in gitk?

A: Select the text, then paste from "*.

NOTE:"* is not the same as "+ which is not working for me.

Hunaphu
  • 589
  • 10
  • 11