Copy and Paste from Tmux window running inside a terminal on Windows WSL/WSL2 - terminal

I have been looking for ways to do this for some time: how do I copy text from my Tmux pane - running inside a windows WSL or WSL2 ubuntu (or other linux distro) terminal - to other windows or WSL-Linux applications. I googled this in the past, and I couldn't find a simple solution. I found a ton of complex suggestions none of which worked (and I certainly didn't have the time to turn that into a time consuming project).
How can I instruct .tmux.conf to expose its clipboard to the windows clipboard? I can't believe this is so complicated.

I am not sure if this answer is what you are asking for, as I have faced a similar problem yesterday and still today - and I have come to the conclusion that most probably only those with a demoniac intelligence and a lot of free time on their hands are able to tweak Tmux and achieve the goal elegantly.
Having said this, I have found a workaround that works for me, inspired by how I was able to do copy&paste on MS-DOS terminals in Windows in the past.
A picture is probably worth one thousand words here:
Click on the top left icon, Edit -> Mark, select text to copy.
Press Enter (or Click on the top left icon again and go for Edit -> Copy)
It did the job for me.

Related

Clear terminal without clearing first line of multi-line prompt

I'm trying to setup the terminal on my new Mac to match the behavior of my old Mac, however I have run into an issue with my multiline prompt that has me stumped. I remember having this issue when I setup my old Mac several years ago, however I don't remember how I solved it.
My prompt (without color) looks like this:
╭─username ~ 130 ↵
╰─
When I press ⌘commandK in iTerm2 on my old Mac it clears the terminal window so that both lines of the prompt are shown at the top.
When I press ⌘commandK in iTerm2 on my new Mac it clears the terminal window so that only the second line of the prompt is shown at the top.
I have tried checking everything I could think of, I have checked:
Every dot file/directory in my home directory (copied them to the new Mac).
iTerm2 settings.
System settings (primarily keyboard shortcuts).
Various websites with instructions about setting up multi-line prompts.
Interestingly I have discovered that if I type clear iTerm2 will clear the screen and leave the top line showing on both Macs. However it first clears the entire screen, including the prompt, before bringing the prompt back (looks bad imo). However since it works differently ⌘commandK does I don't think that's what my old Mac is doing.
It's possible that I installed some program/script that somehow does this, but if so I'm not finding it locally or referenced online.
Does anyone know how I can get ⌘commandK working to clear the screen while keeping the top line of my prompt? I still have the old Mac so I can check/compare anything on it to the new Mac if there are any guesses about what settings I changed.
Edit:
I was able to find something that worked, however if anyone has any other suggestions I'll be happy to try them and accept any that I can make work that are less hacky than this (e.g. don't require another 3rd party app).
Edit: This doesn't work while a command is running, nor does it clear the scrollable history. So it's better than nothing but still doesn't behave like I want it to.
After coming back to my question SO associated a new question with an answer I was able to make work, although it feels extra hacky and wasn't what I had working before.
I found this answer which suggests using ⌃controlL to clear the screen. That does exactly what I want it to do (leaves the top prompt visible and doesn't flash) but with the wrong keybinding. Fortunately I was able to use an app I already have installed (BTT) to make ⌘commandK map to ⌃controlL only in iTerm2.

Identifying menu system

Back when I was a kid, we used an old MS-dos system to navigate programs, menus and games. All I can seem to remember is that we started the program by typing "menu" (or it was in the autoexec). I can't recall further about the name.
This was back in the beginning of the 90'es, but the system could have been developed earlier, but I recall using the cd and cd.. to navigate earlier than that.
I also remember that you could edit the menus by adding/removing items by pressing SHIFT-F[x] (I could be wrong about the shift, but it was an modifier and an F-key), and an item was added by modifying a number of batch-commands. This could either be a new page of menues or a command to a program.
My memory tells me that it looks something like this;
Can anyone tell me more about what this program was called and maybe even if it is available as download somewhere?
(Edit: Updated title)
I remember DrMenu and Fixed Disk Organizer (from IBM) but I don't remember their appearance.
I remember a similar program on my fathers PC (or rather AT) back in the late 80's/early 90's. I think it was made by Scandinavian PC Systems, or SPCS for short. I doubt Visma (that now own the brand SPCS) have it for download somewhere, and my answer is not a complete answer but I can not add a comment so I hope you excuse me for trying to help out in this way.

Remap keys in OS X

Specifically I'm attempting to map my MacBook's fn key to left mouse click.
Back in the old days when I was using Windows, I came across a wonderful little utility that let me map anything to anything: http://www.autohotkey.com/
You create a little text file, e.g.
^!s:: ; CTRL + ALT + s
Send Sincerely,{enter}John Smith ; sends keystrokes to active window
return
Creating a simple text file was infinitely better than any GUI based remapper.
I can look through it and see everything that is going on at a glance
I can customise every last detail
I can save / retrieve / post / share my scripts
Really, it's the one thing I really miss about Windows.
So my question is: How do I go about doing this in OS X? Every Google search leads to https://pqrs.org/macosx/keyremap4macbook/ and I dislike this package: it has an insanely cluttered GUI.
I would be very happy if I could do it in a shell script, or even compile code.
HotKeys on OS X
Even though AHK is seemingly absent on Mac, the functionality that AHK provides on Windows can likely be achieved in OS X. It could be a matter of coding your own solution, modifying something that's open-source, or using a combination of applications that will work together. I haven't tried all of the following, but might as well mention them as they might be worth checking out:
Open Source
IronAHK - .NET rewrite of AHK ported to OS X
AHK Forum Thread
Github Project
*the original project might be dead
CliClick - command-line application that will emulate mouse clicks
Github Project
Commercial
TextExpander - scriptable text completion / hotkey / macro app (supports AppleScript, Shell scripts)
Typinator - similar to TextExpander, although some features vary.
KeyMo - mostly for mapping keys exclusively to your mouse.
FastScripts - maps hotkeys/user-definable keyboard shortcuts to AppleScripts
*I use Text Expander and FastScripts together and can't live without them.
Rolling Your Own
It's fairly easy to create something with an AppleScript, or a shell script for just about anything imaginable in OS X. For example, I've seen CliClick used along with a custom AppleScript to achieve a certain functionality that it might not provide otherwise. To find an AHK replacement on Mac it'll probably be through trial and error, patience, and ultimately what ends up working best for you.
It is possible with a program called ControllerMate, instructions here. It is, however, a commercial software. I'm also interested in finding a free alternative.
Sikuli project looks promising. Not sure about your particular problem (e.g. Fn key remapping), but it's definitely a crossplatform alternative to AHK.
Another Open Source solution to this problem not mentioned in l'L'l's answer is Karabiner; I have been looking for a way to remap the key to the left of 1 to Esc for a while, and this worked perfectly. It even resolved an issue I was having where swapping Cmd and Alt using the built in OSX key remapping was breaking terminal Alt shortcuts! Highly recommend it.

Configure gnome-terminal so that right click extends selection rather than displays menu

I've been using Linux for a long time, but have only recently 'upgraded' to a full GUI desktop since using it command-line-only for the last three or four years. I used to use 'aterm' before then (with fluxbox, and other old-school things) but I see now that gnome-terminal is pretty usable in Ubuntu's Gnome.
However, there's one thing that really gets me - when you select something and then right click, it doesn't extend the selection, instead it brings up a pop-up menu.
I've been using terminals and emacs for years and right-click has always extended a selection - so there must be some way to configure gnome-terminal to do this. This is a habit I'm not going to be able to grow out of because I use it all the time in emacs.
Does anyone have the magic recipe to restore the behaviour I'm after please?
Alternatively, what's a good and modern alternative to gnome-terminal?
I'm using Ubuntu 10.04.
Try program called terminator.
sudo apt-get install terminator
As #bruce-van-der-kooij rightly pointed out, the answer is to Shift+LeftMouseClick, which extends the selection.

Update desktop "show window contents while dragging" setting programatically

One of my programs seems to be changing the Display Properties > Appearance > Effects > Show window contents while dragging setting to off every few hours.
I'm not sure exactly which program, or when it happens. I have a number of programs that seem like likely culprits - wallpaper rotators, software for multiple monitors, multiple virual desktops and switching, and a few others.
I am just thinking to create a little batch script to run periodically and set the setting back to on.
Does anyone know how to do this in windows? I'm using xp pro sp3.
Thanks!
The best option is to do this programmatically using the supported API. i haven't tested this, but it should do the trick:
SystemParametersInfo(SPI_SETDRAGFULLWINDOWS,
TRUE,
NULL,
SPIF_UPDATEINIFILE | SPIF_SENDCHANGE)
You can use SPI_GETDRAGFULLWINDOWS to see if the the bit has been flipped to avoid unnecessarily triggering a WM_SETTINGCHANGE.
You can use RegMon to find the program that keeps changing your settings. Maybe that's a better start than hacking around it.
There is a simple and effective solution to this problem. In Notepad type the following lines :
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Control Panel\Desktop] "DragFullWindows"="1"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\DragFullWindows] "CheckedValue"=dword:00000001 "UncheckedValue"=dword:00000001
Save the file as "Show Window Contents.reg" Double clicking this file and restarting will cure the problem permanently. Post a message if you find this useful.
Aravind Banerjee
It seems the registry setting which controls that preference is HKCU\Control Panel\Desktop\DragFullWindows. You can read more about it here. However, trying it on my own computer does not register the change right away, so a batch script won't do it. You'll probably have to write a program to manipulate it using SystemParametersInfo(). You can pass it the SPI_SETDRAGFULLWINDOWS parameter. Here's a page explaining it more. Here's a page showing how to call it, albeit not for the same parameter.
I suspect it's kept in the registry - maybe [HKEY_CURRENT_USER\Control Panel\Desktop] - "DragFullWindows"?
It would be easy to flip the registry setting back to "1" every hour or so with a batch file.

Resources