Scripted access to Linux clipboard from terminal - linux

I'm using a terminal emulator (MATE, to be exact) running on Linux Mint, which is running in a VM hosted by Windows. I'm connected to a bash shell on CentOS Linux via ssh. I'm not using X-anything. I am able to copy and paste, using the mouse, between my MATE emulator and Windows.
What I want is to write scripts that can read from, and write to, the buffer that Mint uses for cutting and pasting. Once upon a time, on some other *nix (Cygwin, perhaps?) it appears like I could read and write /dev/clipboard, but there's no such thing in Mint. Mac OSX has pbcopy and pbpaste, and there are apparently plenty of solutions when using X-Windows, but none of these seem to address my 'terminal' environment, from all my googling.
I'd like to be able to scrape text from my MATE terminal (or a Windows window, which auto-synchronizes its clipboard with that of Mint) using my mouse, and then run a Perl script that filters that text somehow. Or conversely, have a script on Mint populate the clipboard allowing me to paste elsewhere. Can this be done?

The mouse selection is the PRIMARY selection. The copy selection is the CLIPBOARD selection. Both can be accessed with xclip.

Related

Change shortcuts in Windows to Linux layout

I use Visual Studio Code at work under Ubuntu and at home under Windows. Strangely enough, the shortcuts are different for basically every command. I'm looking for a way to change the layout under Windows to match that of Linux without inputting every single shortcut by hand. Is there a way?

Copy/pasting feature in codeblocks in linux

I have installed Code::Blocks 12.11 in my linux mint but pasting input at runtime in the command line(I think it is called command line)doesn't seem to work.I have to type the whole input inorder to get output.Can anybody tell me how to fix this?
P.S :- I have tied ctrl+V as well as right click and paste but nothing really working in my case
This problem arises when you have xterm as your launch terminal.You can solve this by switching your terminal from xterm to gnome-terminal.
Go to Settings -> Environment -> Terminal to Launch Console Programs
and change the launch terminal from xterm to gnome terminal from the options.
In the terminal, for copy and paste:
Shift+Ctrl-c and Shift+Ctrl-v
In the Xterm, for pasting:
Middle click or Shift-Insert
if you want to copy in the xterm, you just select the text with your mouse and paste using the middle click or Shift-Instert, but it just works inside the xterm.

How to copy text to system clipboard in emacs while working in terminal buffer?

I usually use emacs in a text terminal environment to manipulate text. In some particular situations, however, I want to interact with the system's clipboard, for example, copy text from emacs to a website. Is it possible to yank text to the system's clipboard directly from or to emacs? How?
Terminal in emacs is nothing but a buffer. If you are running terminal using eshell, you can directly copy to clipboard using M-w like you do in normal buffer.
If you are running terminal using ansi-term, yanking/copying is little tricky. You need to go to term-line-mode using C-c C-j copy whatever you want and come back to term-char-mode using C-c C-k. See this answer for more info.
There's support for doing just that in Emacs-25 (see the NEWS file, looking for xterm-extra-capabilities), tho it depends on your terminal emulator providing corresponding support, which is apparently usually disabled by default, so you additionally need to configure your termninal emulator as well.
Another option is to install the xclip package, which is available on GNU ELPA.
This article (http://blog.binchen.org/posts/copypaste-in-emacs.html) helps me. In it, the author implement a function to fulfil such a task.

Select(mark) & right click paste feature (like on cisco's IOS) on linux (bash)

Is it possible to make/enable/config bash on linux to be able to copy content from terminal by just selecting it and to paste by right click (like when you connect to switch/router with ssh)?
Yep it is in fact it's on by default in most terminals see below for example. Ctrl-Shift-C & Ctrl-Shift-V are also very helpful in this regard. I'm using konsole in KDE but gnome-terminal and nearly every other terminal has this ability.
Without X/Gnome/KDE: if you install gpm you can use your mouse for copy/mark and paste on console.

alt-tab like functionality when using terminal?

When working in GUI we do alt-tab (or cmd-tab in mac) to switch between multiple programs, for example I am writing a text file in a text editor and then I do alt-tab to switch to already running browser to google up something then I alt-tab again to come back to keep editing.
How do you perform such "switch between" programs in command line interface - for example working with a ssh command line shell?
EDIT: I forgot to mention it, I am using ssh to connect to my university's server, and they don't have screen & tmux installed, and my account have no right to install any new apps... Is there any built-in functionality to perform this task, or any work around? For exmaple can I "minimize" running proggram and come back to regular shell interface, do some work, then display the "minimized" process again?
Another workaround: use the shell's job control, eg if you're editing a file, CTRL-z pauses the editor and brings you back to the shell, where you can compile, see manpages, browse the web or whatever -- and of course you can background the browser or anything else.
Screen command offers the ability to detach a long running process (or program, or shell-script) from a session and then attach it back at a later time.
As a crude workaround, run multiple terminal windows on your computer, and alt-tab between them.
Incidentally, at the Linux console, you can switch virtual terminals with ctrl+alt+F for at least F1 through F6, commonly F8 or more (depends on how the distro sets them up). Not your case, I know, but in case future visitors should benefit.
If you are comfortable in Emacs, it allows you to run multiple independent ansi-term buffers.
You can also use "GNU screen" to emulate multiple terminals in one terminal.

Resources