Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Copy text from terminal outputs ^C
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
KarlP
n00b
n00b


Joined: 10 Sep 2017
Posts: 38
Location: Vorderstoder, Austria

PostPosted: Sun Sep 10, 2017 7:33 pm    Post subject: Copy text from terminal outputs ^C Reply with quote

Hallo!

I am new to gentoo and have started to set up my installation last August.

From the days when I started to work with linux in the early 2000s I have used Ctrl+Shift+C in terminals for copying text. At least I can't remember that I have ever had trouble with Ctrl+Shift+C / Ctrl+Shift+V for Copy and Paste.

Now with my first gentoo I am annoyed by the strange behaviour in lxterminal that outputs ^C when copying text. Regrettably I did not succeed with my searches in the net to find a solution.

My DE is lxde.

Could you please help.

Karl


Last edited by KarlP on Mon Sep 11, 2017 10:12 pm; edited 2 times in total
Back to top
View user's profile Send private message
Tony0945
Watchman
Watchman


Joined: 25 Jul 2006
Posts: 5127
Location: Illinois, USA

PostPosted: Sun Sep 10, 2017 8:29 pm    Post subject: Reply with quote

I use several DE's (not LXDE howver). I never had trouble highlighting text with the mouse (left mouse down then drag the mouse), then right clicking the mouse to get the menu which should include "copy" and also "paste".
Back to top
View user's profile Send private message
KarlP
n00b
n00b


Joined: 10 Sep 2017
Posts: 38
Location: Vorderstoder, Austria

PostPosted: Sun Sep 10, 2017 9:51 pm    Post subject: Reply with quote

Thanks for your reply. But that doesn't answer my question. It is not my mouse that is making trouble. It is entering Ctrl+Shift+C in the keyboard!

I avoid using the mouse as much as I can. Sorry, that I missed to mention this antiquated habit.
:wink:
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21600

PostPosted: Sun Sep 10, 2017 11:14 pm    Post subject: Reply with quote

Whether Ctrl+Shift+C is handled specially depends on the terminal and on its configuration. All terminals I remember using pass it through as a regular ^C. On the system that treated that as copy, was that also LXDE with lxterminal? If not, what terminal did you use before?
Back to top
View user's profile Send private message
KarlP
n00b
n00b


Joined: 10 Sep 2017
Posts: 38
Location: Vorderstoder, Austria

PostPosted: Mon Sep 11, 2017 6:12 am    Post subject: Reply with quote

Yes, as I mentioned in my first post it was lxterminal. By the way, I just checked in SystemRescueCd where Xfce Terminal Emulator is used. Ctrl+Shift+C goes without ^C. The same in Xterm.

I have found a good explanation on
https://wiki.archlinux.org/index.php/Copying_text_from_a_terminal
But I couldn't figure out how to change this behaviour.
Back to top
View user's profile Send private message
R0b0t1
Apprentice
Apprentice


Joined: 05 Jun 2008
Posts: 264

PostPosted: Mon Sep 11, 2017 6:59 am    Post subject: Reply with quote

Not sure if you still couldn't copy: With most X11 virtual terminals, selecting the text will put it in the non-desktop clipboard. Use middle mouse to paste. There is generally a menu for keyboard chords in a terminal emulator (unless it's something like urxvt). Have you found it?
Back to top
View user's profile Send private message
KarlP
n00b
n00b


Joined: 10 Sep 2017
Posts: 38
Location: Vorderstoder, Austria

PostPosted: Mon Sep 11, 2017 10:52 am    Post subject: Reply with quote

I am sorry for having caused misunderstandings.

The issue is not that it’s not possible to copy and paste. The issue is that entering Ctrl+Shift+C in the keyboard is accompanied with the output of the string “^C” to the terminal + opening a newline.

That’s inconvenient for instance when one wants to compose a command by selecting snippets from other elements already appearing in the terminal and pasting them to the command line.
Back to top
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10587
Location: Somewhere over Atlanta, Georgia

PostPosted: Mon Sep 11, 2017 2:41 pm    Post subject: Reply with quote

Afraid not. lxterminal is rather minimalistic and does not contain any shortcut key configurability.

- John
_________________
I can confirm that I have received between 0 and 499 National Security Letters.
Back to top
View user's profile Send private message
Fitzcarraldo
Advocate
Advocate


Joined: 30 Aug 2008
Posts: 2034
Location: United Kingdom

PostPosted: Mon Sep 11, 2017 2:49 pm    Post subject: Reply with quote

You could try adding the shortcuts to ~/.Xresources then logout and login again for them to take effect.

Code:
$ cat ~/.Xresources
XTerm*vt100*translations:   #override                       \n \
    Shift Ctrl <KeyPress>C: copy-selection(CLIPBOARD)       \n \
    Shift Ctrl <KeyPress>V: insert-selection(CLIPBOARD)     \n

That stops lxterminal issuing ^C in my case, and does indeed copy the highlighted text.
_________________
Clevo W230SS: amd64, VIDEO_CARDS="intel modesetting nvidia".
Compal NBLB2: ~amd64, xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC udev elogind & KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
KarlP
n00b
n00b


Joined: 10 Sep 2017
Posts: 38
Location: Vorderstoder, Austria

PostPosted: Mon Sep 11, 2017 5:53 pm    Post subject: Reply with quote

Regrettably this doesn't help either.

And my guess is that this behaviour depends on the compilation of some of the components involved in lxterminal. This seems most probable to me because I didn't need a Xresources-file before when I used other Distros.

But where to dig further?
Back to top
View user's profile Send private message
Fitzcarraldo
Advocate
Advocate


Joined: 30 Aug 2008
Posts: 2034
Location: United Kingdom

PostPosted: Mon Sep 11, 2017 7:00 pm    Post subject: Reply with quote

What key bindings do you have in in your ~/.config/openbox/rc.xml file?

EDIT: Something along the following lines in the keyboard section of rc.xml might do it:

Code:
<keyboard>
...
<!-- Ctrl+Shift+c Copy X selection to clipboard -->

    <keybind key="C-S-c">
      <action name="Execute">
        <command>sh -c 'xsel -o | xsel --clipboard'</command>
      </action>
    </keybind>
...
</keyboard>

_________________
Clevo W230SS: amd64, VIDEO_CARDS="intel modesetting nvidia".
Compal NBLB2: ~amd64, xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC udev elogind & KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
KarlP
n00b
n00b


Joined: 10 Sep 2017
Posts: 38
Location: Vorderstoder, Austria

PostPosted: Mon Sep 11, 2017 9:20 pm    Post subject: Reply with quote

These are my key bindings of my ~/.config/openbox/lxde-rc.xml:

Code:

  <!-- Keybindings for desktop switching -->
  <keybind key="C-A-Left">
    <action name="DesktopLeft"><dialog>no</dialog><wrap>no</wrap></action>
  </keybind>
  <keybind key="C-A-Right">
    <action name="DesktopRight"><dialog>no</dialog><wrap>no</wrap></action>
  </keybind>
  <keybind key="C-A-Up">
    <action name="DesktopUp"><dialog>no</dialog><wrap>no</wrap></action>
  </keybind>
  <keybind key="C-A-Down">
    <action name="DesktopDown"><dialog>no</dialog><wrap>no</wrap></action>
  </keybind>
  <keybind key="S-A-Left">
    <action name="SendToDesktopLeft"><dialog>no</dialog><wrap>no</wrap></action>
  </keybind>
  <keybind key="S-A-Right">
    <action name="SendToDesktopRight"><dialog>no</dialog><wrap>no</wrap></action>
  </keybind>
  <keybind key="S-A-Up">
    <action name="SendToDesktopUp"><dialog>no</dialog><wrap>no</wrap></action>
  </keybind>
  <keybind key="S-A-Down">
    <action name="SendToDesktopDown"><dialog>no</dialog><wrap>no</wrap></action>
  </keybind>
  <keybind key="W-F1">
    <action name="Desktop"><desktop>1</desktop></action>
  </keybind>
  <keybind key="W-F2">
    <action name="Desktop"><desktop>2</desktop></action>
  </keybind>
  <keybind key="W-F3">
    <action name="Desktop"><desktop>3</desktop></action>
  </keybind>
  <keybind key="W-F4">
    <action name="Desktop"><desktop>4</desktop></action>
  </keybind>
  <keybind key="W-d">
    <action name="ToggleShowDesktop"/>
  </keybind>

  <keybind key="C-A-d">
    <action name="ToggleShowDesktop"/>
  </keybind>

  <!-- Keybindings for windows -->
  <keybind key="A-F4">
    <action name="Close"/>
  </keybind>
  <keybind key="A-Escape">
    <action name="Lower"/>
    <action name="FocusToBottom"/>
    <action name="Unfocus"/>
  </keybind>
  <keybind key="A-space">
    <action name="ShowMenu"><menu>client-menu</menu></action>
  </keybind>

  <!-- Keybindings for window switching -->
  <keybind key="A-Tab">
    <action name="NextWindow"/>
  </keybind>
  <keybind key="A-S-Tab">
    <action name="PreviousWindow"/>
  </keybind>
  <keybind key="C-A-Tab">
    <action name="NextWindow">
      <panels>yes</panels><desktop>yes</desktop>
    </action>
  </keybind>

  <!-- Keybindings for running applications -->
  <keybind key="W-e">
    <action name="Execute">
      <startupnotify>
        <enabled>true</enabled>
        <name>PCManFM</name>
      </startupnotify>
      <command>pcmanfm</command>
    </action>
  </keybind>

  <!--keybindings for LXPanel -->
  <keybind key="W-r">
      <action name="Execute">
        <command>lxpanelctl run</command>
      </action>
  </keybind>

  <keybind key="A-F2">
      <action name="Execute">
          <command>lxpanelctl run</command>
      </action>
  </keybind>

  <keybind key="C-Escape">
      <action name="Execute">
          <command>lxpanelctl menu</command>
      </action>
  </keybind>

  <keybind key="A-F1">
      <action name="Execute">
          <command>lxpanelctl menu</command>
      </action>
  </keybind>

  <keybind key="A-F11">
     <action name="ToggleFullscreen"/>
  </keybind>

    <keybind key="Super_L">
    <action name="Execute">
    <command>lxpanelctl menu</command>
    </action>
    </keybind>

<keybind key="C-A-l">
  <action name="Execute">
    <command>xscreensaver-command -lock</command>
  </action>
</keybind>

  <!-- Launch Task Manager with Ctrl+Alt+Del -->
  <keybind key="A-C-Delete">
      <action name="Execute">
          <command>lxtask</command>
      </action>
  </keybind>

  <!-- Launch gnome-screenshot when PrintScreen is pressed -->
  <keybind key="Print">
      <action name="Execute"><command>gnome-screenshot -i</command></action>
  </keybind>

  <!-- Launch LXRandR when Fn+Screen is pressed -->
  <keybind key="XF86Display">
      <action name="Execute"><command>lxrandr</command></action>
  </keybind>
Back to top
View user's profile Send private message
KarlP
n00b
n00b


Joined: 10 Sep 2017
Posts: 38
Location: Vorderstoder, Austria

PostPosted: Mon Sep 11, 2017 9:45 pm    Post subject: Reply with quote

Fitzcarraldo

Thanks for your message (Mo Sep 11, 2017 7:00 pm).

With the keybind you recommended it finally works!


EDIT: Reporting a success was to early! The behaviour now changed so that Ctrl+Shift+V does not paste any more. The same in gvim. Copying with Ctrl+Shift+C can only be used together with Shift+Ins.
Back to top
View user's profile Send private message
Fitzcarraldo
Advocate
Advocate


Joined: 30 Aug 2008
Posts: 2034
Location: United Kingdom

PostPosted: Mon Sep 11, 2017 10:49 pm    Post subject: Reply with quote

KarlP wrote:
Reporting a success was to early! The behaviour now changed so that Ctrl+Shift+V does not paste any more. The same in gvim. Copying with Ctrl+Shift+C can only be used together with Shift+Ins.

Try adding a key binding for pasting, then:
Code:
<keyboard>
...
<!-- Ctrl+Shift+v Paste clipboard contents -->

    <keybind key="C-S-v">
      <action name="Execute">
        <command>sh -c 'xsel -o | xvkbd -xsendevent -file -'</command>
      </action>
    </keybind>
...
</keyboard>

If not already installed, you'll need to install xvkbd as well as xsel.


EDIT: Added missing '-o' option to xsel command.
EDIT2: Tested in LXDE/Openbox in a VirtualBox VM and it works for me.
_________________
Clevo W230SS: amd64, VIDEO_CARDS="intel modesetting nvidia".
Compal NBLB2: ~amd64, xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC udev elogind & KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
Fitzcarraldo
Advocate
Advocate


Joined: 30 Aug 2008
Posts: 2034
Location: United Kingdom

PostPosted: Tue Sep 12, 2017 5:46 pm    Post subject: Reply with quote

See the post https://forums.gentoo.org/viewtopic-p-8116888.html#8116888 as it might be helpful:

PQPGuy wrote:
Fitzcarraldo, you are right, once again. I run LXTerminal v. 0.1.11. So, let's upgrade to v. 0.2.0-r1 (which is currently unstable) and see what happens.

UPDATE: upgrading made the problem go away! The new version allows the keybindings (like copy, paste, etc.) to be set through Preferences.

_________________
Clevo W230SS: amd64, VIDEO_CARDS="intel modesetting nvidia".
Compal NBLB2: ~amd64, xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC udev elogind & KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
KarlP
n00b
n00b


Joined: 10 Sep 2017
Posts: 38
Location: Vorderstoder, Austria

PostPosted: Tue Sep 12, 2017 10:17 pm    Post subject: Reply with quote

Fitzcarraldo, thank you once again. I have already noticed the thread of PQPGuy.

I have made a test with the key bindings you recommended and they work. But as I have noticed Ctrl+Shift+C / Ctrl+Shift+V is only useful within the terminal. To transfer some text from lxterminal to another program did not work. For instance to take text from lxterminal and paste it into the address line of pcmanfm or to gvim did not work.

The version was lxterminal 0.1.11. Being frustrated I have downloaded the version 0.3.0 from lxde and compiled by myself. Now everything works fine. Sorry for my impatience.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21600

PostPosted: Wed Sep 13, 2017 12:37 am    Post subject: Reply with quote

OP: so the ebuilds linked in lxde-base/lxterminal-0.3.0 version bump (and shown in lxde-base/lxterminal: Bump to 0.3.0) are sufficient for the new version? Based on some of the comments in the bug, it was a bit unclear if the earlier attempts work, and the automated test rejected charles17's work (though the output looks like a spurious rejection due to bad luck/timing), which may discourage the maintainer from pulling it promptly. If the ebuild worked for you, that might encourage the maintainers to merge it.
Back to top
View user's profile Send private message
KarlP
n00b
n00b


Joined: 10 Sep 2017
Posts: 38
Location: Vorderstoder, Austria

PostPosted: Wed Sep 13, 2017 8:33 am    Post subject: Reply with quote

Hu,
I did not use an ebuild, I was not even aware that some lxde-base/lxterminal-0.3.0 version existed! In my /usr/portage I have found only 0.2.0-r1.ebuild and 0.1.11.ebuild. As mentioned at the beginning I am new to gentoo.

What I did was to download the source code from lxde.org and compiled and installed lxterminal by myself.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21600

PostPosted: Thu Sep 14, 2017 1:04 am    Post subject: Reply with quote

To what path did you install it? Installing programs system-wide outside control of the package manager is discouraged because Portage will not consider the requirements of those programs when maintaining the system. Installing under your home directory is fine, if you do not mind managing the dependencies by hand. In general, using an ebuild (from a reputable overlay, if necessary) is preferred so that Portage has a complete view of what is installed on the system.
Back to top
View user's profile Send private message
Hund
Apprentice
Apprentice


Joined: 18 Jul 2016
Posts: 218
Location: Sweden

PostPosted: Thu Sep 14, 2017 8:36 am    Post subject: Reply with quote

I use these two aliases to modify and read the clipboard from my terminal.

Code:
getclip='xclip -selection clipboard -o'
setclip='xclip -selection c'

_________________
Collect memories, not things.
Back to top
View user's profile Send private message
KarlP
n00b
n00b


Joined: 10 Sep 2017
Posts: 38
Location: Vorderstoder, Austria

PostPosted: Thu Sep 14, 2017 9:11 pm    Post subject: Reply with quote

Hu,
you are right, of course. It was brute and dirty what I did.

And I am aware that now - from portage point of view - lxterminal doesn't exist at all on my installation. (I have unmerged lxterminal.0.1.11 in advance and have now /usr/local/bin/lxterminal, i.e. system-wide.)

But reading the line "Fixed issue with 'ctrl-shift-c' accel sending 'ctrl-c' to terminal" in the NEWS document of lxterminal-0.3.0.tar.xz was exactly what I was looking for. So, why should I reinvent the wheel and fiddle with workarounds when the work was already done by the developers? On the other hand, the situation with lxterminal seems somewhat exceptional to me as nothing depends from lxterminal. So, I have thought that this shouldn't be a big issue and I can resolve the problem sometime in the future.

Thank you for your advice.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum