Straightforward way of copying text from byobu to system clipboard? - copy-paste

I frequently want to copy snippets of command outputs to the web browser. Doing so is nice and simple in gnome-terminal (mouse-select, right-click, copy) but seems to be not so straightforwardly possible in byobu.
The procedure for copying outlined in the docs is:
Enter scrollback using alt-pgup or alt-pgdn, press the spacebar to start highlighting text, use up/down/left/right/pgup/pgdn to select the text, and press enter to copy the
text. You can then paste the text using alt-insert or ctrl-a-].
However, this doesn't copy to system clipboard (and seems to involve quite a few keystrokes)
This source suggests using xsel
https://askubuntu.com/questions/33789/how-do-i-integrate-byobus-copy-buffer-with-the-x-clipboard
which doesn't work for me and would be rather less convenient anyway(what if I want to scroll up to several commands earlier that ran in a different context?)
What I would like is, ideally, a way to copy to the system clipboard that works in the same as gnome-terminal eg. highlight -> ctrl+shift+c or right-click copy or some way to integrate the byobu copy buffer with the system copy buffer.
I'm using Ubuntu 16.04 with Gnome and byobu 5.106-0ubuntu1

As pointed out in this comment, holding the shift key seems to be the solution to your problem. So:
Shift+F11 to zoom in on the split that you want to copy from
Shift+select what you want to copy
Shift+right click, copy (or by the way, Shift+Ctrl+C that also works in gnome-terminal)

I had some issues when selecting command outputs bigger than an entire screen, mouse select may be harder on these cases. My preferred method is to use <shift+F7> to capture output from desired split to a new PRINTSCREEN.
After that I select the desired portion of output at PRINTSCREEN using editor shortcuts and then getting it into system clipboard (e.g. using vim select then "+gy).

Related

JetBrains IDE make link clickable in .txt files

I am opening a .txt file with my PyCharm IDE that contains multiple links among several other lines of text (actually these are logs from a continuously running script).
Like so:
----------------------- session start, Tuesday 12.10.2021, 12:48:53
>> some logs... -- 12:49:34
link: https://www.example.com/p/CU5Hn-RsSB9
>> more logs... -- 12:49:34
Now for convenience I would like to be able to click on that link rather than copy/pasting it to my browser - it seems like this should be a possible setting somewhere in PyCharm: But I cannot seem to find it and also not find any information on it on the web.
Anybody knows how to make links clickable in .txt files opened in PyCharm?
The ideal solution you are asking for would be configuring clickable URL links in the editor window but that is not currently supported by PyCharm.
That kind of configuration is hardcoded in the PyCharm IDE. For example, URLs are clickable if they're inside a Python comment or a Markdown file, but they can't be turned on/off; only the colors highlights can be configured (and thus the corresponding dialogues in the settings are an integral part of PyCharm that can't be changed.) Neither is there any way to create new file types with those configurations. You can see one such example by going to File > Settings > Editor > Color Scheme > Markdown and checking the Auto Link item in the list.
In these cases the alternative to your specification would be installing a plugin that implements the functionality. I searched the JetBrains Marketplace but I think no plugin is currently available that implements what you want. (A few are close, like TxtReader or Awesome Console but these still rely on sending the file/output to the console, they don't make the links clickable in the editor window.)
Having said that, the closest native alternative using vanilla PyCharm (without installing plugins) would be running the Terminal as an External tool to read the .txt file. This has the desirable advantage of opening the file inside the IDE and since PyCharm supports several terminals you get the flexibility of using the terminal specific settings you prefer.
Here's an example of configuring PyCharm's External Tool to open the .txt using Window's CMD. (Using the command line arguments /c more is terminal specific. Also notice the use of the $FilePath$ and $ProjectFileDir$ PyCharm specific macros.)
After your External Tool is configured you can use it by right clicking on the open file in the editor window or in the Project files view. In the terminal you can see the .txt file having the clickable URL.
Another alternative could be configuring the IDE's External Tool to launch a 3rd party text editor to open the .txt file; but the main drawback of that approach is it would open the file outside PyCharm.
For me, it looks like you can display a clickable link to a file, provided :
the file exists,
the file is a python file (ends with '.py'),
the file is in the project (the file owns to a directory inside the project)
for example, your file is "main.py" and your project root is "/Users/puiseux/GitHub/myproject" then the two lines
>>> filename = "/Users/puiseux/GitHub/myproject/main.py"
>>> print('File "%s", line %d' % (filename, 12))
will display a clickable link to the line 12 of file "main.py"
File "/Users/puiseux/GitHub/crypto/main.py", line 12
If you do not fulfill one of three conditions, it does not work

Spyder: Disable copying when nothing is selected

In Spyder, ctrl+c will overwrite the previously copied even when the selection is empty, unlike most other applications (apparently Atom and Sublime Text also do this). It frequently happens that I want to paste with ctrl+v, and hit copy instead, which is an annoying waste of time.
Is there a way to disable this behavior?
Sidenote: ctrl+x doesn't overwrite when nothing is selected, so Spyder isn't consistent there.
(Spyder maintainer here) This is the behavior of most applications, i.e. they replace the previously copied text with your new selection. I don't see how we could avoid that, other than maintaining a list of previously copied text so you can go back and select an entry on it.
However, that's something other applications are specifically designed to do (e.g. Klipper on Linux), so you should be better by installing any of them. Their generic name is Clipboard managers.

How to print a file from VsCode?

I want to send the file I'm currently editing to a printer, like I did in Notepad++ for example.
I havn't found any hint on a print command. Is it not possible ?
It is not yet available, but I found an issue report for that feature.
It's currently in the backlog, so we can expect it soon.
https://github.com/Microsoft/vscode/issues/5953
Edit:
In the meantime:
https://marketplace.visualstudio.com/items?itemName=nobuhito.printcode
https://marketplace.visualstudio.com/items?itemName=pdconsec.vscode-print
Now you can install addon for VS Code - search "PrintCode".
Note that the repository for this extension was last updated in February 2018 with numerous issues outstanding.
I found the PrintCode extension inspiring but unfinished and with a number of flaws. In particular it depends on a specific paper size to wrap and as a result does not respond well if you change paper size or orientation in the print dialog.
It's open source so I looked at the code and didn't like that either. No programmer ever likes another's coding style. So I pinched the idea of using a web-browser as platform driver for HTML printing -- my hat is off to the PrintCode author for that cunning insight -- and wrote my own.
In the process I fixed all the known bugs, added everything on my wishlist and a couple of things suggested by others. The biggest thing was figuring out the CSS required to respect print dialog paper size and orientation. This also sorts out the mysterious disappearing line numbers problem, although I'm not sure why. The next biggest thing was learning to probe for an unused port, a problem that also afflicts PrintCode causing the browser to open showing no content.
Major issues
PrintCode depends on a web service. You can't use it offline.
Many people want to be able to open a file, select a portion and print just the selection.
The print dialog supports changing paper size and orientation. This clashes with the way PrintCode works.
Some people like to run multiple VS Code windows.
When you print a markdown file, you probably don't want it printed like a text file when it can be rendered with fonts and proper headings and bullets etc.
Support is required for remote workspaces.
Because each instance of VS Code needs a different port for its embedded webserver, you can't just use a setting. Dynamic port allocation is necessary.
Remote workspaces weren't even a thing until two years after maintenance ceased on PrintCode.
If you want to survey your options, get onto https://marketplace.visualstudio.com, choose the Visual Studio Code tab and search for printing.
If you just want a link to my version, it's here http://marketplace.visualstudio.com/items?itemName=pdconsec.vscode-print.
If you like what you see but need something I haven't thought of, the marketplace page has a link to the repo on github. Create an issue and tell me what you need -- or write it yourself and submit a PR.
Now there is an extension available for printing from the VS Code Editor.
It's called VS Code Printing Free.
I've tried it for a couple of days and it works fine.
Poor man's answer: Copy code to Notepad2 or Notepad++ and print from there.
The colour coding will be different though
You can use an Extension of VS Code: PrintCode
Install extension PrintCode
On Mac: command + shift + P
choose command> PrintCode
I have modified the https://marketplace.visualstudio.com/items?itemName=pdconsec.vscode-print. If you change the values that I have marked in the picture in the extension settings a browser tab opens with the you can then print this also works on the Ipad. It works also with the code-server Version inside a Docker Container.
I put the file on github https://github.com/chrishdx/vsc-print
enter image description here

What solutions are available to automate keystokes and entry of incrementing filenames?

I am assembling image sequences, each sequence consisting of 1-5K png images. Each sequence is then subject to a large number of image manipulations. These manipulations are identical for each image, though may be slightly different from sequence to sequence. I wish to automate this whole operation. I can automate all the image manipulations using tools I have (PaintShop Photo Pro, IrfanView32, among others). The problem I have is automating the first step - the assembly of the images initially.
The images are produced from a tool, written in Java. There is no access to the source for this tool. In addition the tool was written in a GUI style derived in the Unix world. The implications of this are that normal Windows shortcuts are not necessarily recognised by the tool (eg Alt-F for the file menu; some buttons do not have shortcuts; etc). The tool provides two windows - a control window and an image window.
The sequence of actions I need to carry out to derive the images is as follows:
Initial steps (no automation needed).
Run tool
Load an initialisation file from the control window
Use the image window to setup the image full screen at the required magnification
Load a log file from the control window (format not available outside the tool)
The repetitive steps are:
Press a button in the image window to generate the image
Enter a file name in the resultant dialog box. This file name will need to have a root applicable to the sequence plus a unique increasing number (5 digit in string form) specific to the image.
Press a button in the control window to advance the log file
One final twist - the only way of determining the end of the sequence is that the tool indicates the end of log file by disabling the button on the control window. There is no other indication of EOF readily available.
My first thought was to use Microsoft's Powershell, but my limited understanding of that tool suggests that the Unix/Windows/GUI incompatibilites and the lack of availability of the java objects, precludes this approach.
My environment is Windows 7 Ultimate 64; development tools available to me are Delphi XE, 2006, 7; there are a number of other languages installed (Java, Python, Haskell).
What approaches and/or tools will enable me to automate this task. As a sole developer, my preference is for free or cheap tools.
AutoHotkey is a powerful tool which can fit your needs.

Configure native vi to emit spaces instead of tabs and not convert autoindent spaces to tabs?

I would like to use spaces instead of tabs when editing Perl scripts with the native vi found on Solaris systems.
I know this can be done with the vim clone, but I don't have access to install vim on these systems as they are vendor locked.
Firstly, is there a way to configure vi to emit spaces when I press TAB?
And secondly, I am also using the auto-indent feature of vi:
:set ai
The problem is, when I manually enter spaces for indenting vi converts groups of 8 spaces into tabs automatically when it does auto-indenting. I guess if I can find a way to turn this functionality off it will be a start.
For an outside-the-box option, could you export the Solaris filesystem using NFS and edit the files you need on another system with a more capable editor?
I believe you want
:set et
(short for expandtabs). I think vi classic supports it.
I realize this is well beyond the best-by date, but I just ran into this issue and was looking for an answer myself. A real pain when editing yaml on a FreeNAS box.
Anyhow, I successfully dealt with the issue by setting the value of tabstop to a large value.
':set tabstop=1000'

Resources