How to delete highlighted text in a ssh terminal? - putty

I know that I can highlight text and its automatically copied, but is there a way to delete the text that you highlight? I am using nano.

Assuming you're using PuTTY on Windows, here is the way the applications are stacked:
You -> Windows -> PuTTY -> SSH protocol -> sshd -> Unix pty -> nano -> filesystem
PuTTY talks to Windows, so it knows about your mouse. And it can do things like interact with the Windows clipboard. On the other hand, nano isn't even running on your computer, it's running on the remote computer. So it doesn't know anything about your mouse or your Windows clipboard. It only knows about what it can talk to through a tty device (usually a pty, or "pseudo-terminal" device).
When you're running nano locally (on a Unix desktop, in xterm or something similar), nano talks to xterm, and can get mouse information from the terminal (if mouse support is enabled in nano).
To get mouse support in nano, try using nano -m, or put "set mouse" in your ~/.nanorc. You may want to browse the nano documentation for more information. Additionally, you may need to do export TERM=xterm or similar in your shell if PuTTY isn't in your termcap file.
With mouse support on, nano will use xterm-compatible terminal extensions to talk through SSH to PuTTY. Then you will be able to cut and paste (and delete text) in nano, but you won't be able to cut and paste text with the Windows clipboard anymore. (If you want the old behavior back, you can hold down shift while you select. See the PuTTY documentation for details.)

Ususally, no. The issue is that the terminal doesn't have any knowledge of the mouse and what the mouse highlights - it's very low level. In other terms, the mouse sits on a "higher layer" than the terminal; nothing the mouse does is known to the terminal.

Related

In mosh how can I scrollback in the terminal and use mouse in emacs, less etc

I want to use mouse-wheel in emacs and also scroll-back in the terminal history. When I do mosh --no-init I can scroll-back in the terminal history but I cannot use mouse wheel in the emacs. Instead if I do only mosh without --no-init flag I can use mouse-scroll in Emacs but cannot scroll back in the terminal history. I get lost in finding solution to fix this.
In mosh is it possible to scroll-back in the terminal history along with using mouse wheel in emacs, nano, less?
mosh prevents the use of scrollback #122
The root cause of not able to scroll is caused by mosh entering a
"alternative screen" mode. It can be disabled using the --no-init flag
(see the doc). Just alias mosh='mosh --no-init' and the problem
will go away.
Developers argue that:
I don't consider using --no-init as a way to get reliable access to a local scroll-back buffer. But please interpret this open issue as simply an acknowledgement of the request. We do not have any intention on implementing this feature
And recommended me from a issue I opened to use screen or tmux as a solution. But I was not able to make them work. Where when I use tmux inside the remote machine I experience that:
Scroll-back in the terminal history works, but it prevents me to copy some text from previois terminal history, it jumps back to current cursor spot right away.
Scroll-back does not work within emacs, less, nano etc.
My comment in their repsonde to mosh prevents the use of scrollback #122 labelled as This comment was marked as off-topic., which was what I mentioned in this question.
Their issue related to mosh prevents the use of scrollback #122 was open since 2012, which is around 8 years and I believe it is abandoned. If it is implemented it was implemented by now.
Contributors of mosh ignoring this issue. and saying There is hundreds of subscribers. Please think very carefully before commenting . // There was not hundreds of subscribers in the thread.
In summary, I am not having issue with --no-init, I am having issue with mosh related to mosh prevents the use of scrollback #122 , which does not support scroll back in terminal history along within tools like emacs, nano, vim, vi, less, more and so on. If a developer switching from ssh to mosh there is no way he/she can adapt the scroll behavior of mosh. Without having both together like ssh does, there is no meaning to use mosh at all.

Enable vi mouse wheel scrolling using bash on ubuntu on windows 10

I'm using bash on ubuntu on windows 10 and would like to enable scrolling using the mouse wheel in vi or vim. I've tried entering the following command in vim and added it to the .vimrc file and /usr/share/vim/vim74/debian.vim
set mouse=a
However I still can't scroll with the mouse.
I added this to my /etc/vim/vimrc.local, and it worked:
set mouse=a
map <ScrollWheelUp> <C-Y>
map <ScrollWheelDown> <C-E>
Quick and simple answer:
If you use mintty/wsltty it works just fine!
You have done, properly, all you can in vim and the problem is with your terminal emulator.
Mouse wheel scrolling through the scrollback buffer of a terminal emulator is a function of the terminal emulator which is consuming the mouse events. You are wanting to send these events to the application (vim) hooked to the terminal.
Most terminal emulators have a way to enable the passthrough of mouse events when in "Application Key Mode" or "Alternate Screen". Most also support using a modifier key (like holding ALT) that will passthrough the mouse events as you wish.
Your version of Vim may not have been compiled with mouse support. See if you can get gvim. It contains a graphical version of Vim. Depending on your distribution it may also contain the terminal vim with almost all features enabled, including mouse support.
To check for mouse support in Vim, enter :version and check whether +mouse is in the list of features.

How do you duplicate a shell instance in Unix?

My specific problem is the following: I am using Mac OS X with the Visor app for terminal. This lets me do cool pop-in/out stuff with terminal for quick access. The problem is, I lose the ability to move the window around and re-size it, something that becomes important when I start opening up multiple buffers in emacs and want to view some at the same time in a window larger than 80 wide.
Does anyone know how to duplicate a shell window/instance, so that a new window appears with the same history, current working dir, aliases, etc...? Even more specifically, can this be done in Mac OS X such that the new window is in a different "style", (basic, pro, sands, etc..).
I'm not familiar with Visor, but simply using a terminal emulator such as screen might give you what you need. From a terminal, invoke 'screen'. That will give you a shell prompt. From another terminal, invoke 'screen -x'. Now each terminal will be attached to the same shell, with the same history, etc. See screen(1) for details.

Scrolling inside Vim in Mac's Terminal

I've been googling around trying to figure out if it's possible to use my mouse wheel to scroll while inside Vim in Mac's Terminal, with no luck. It seems as if only X11 or iTerm support this.
Before I give up, I thought I'd try the geniuses here to see if anyone knows a way to do this. So, does anyone know if I can set that up?
Or should I seriously consider using a different terminal application?
And if you're using iTerm, add this to your vimrc
:set mouse=a
http://bitheap.org/mouseterm/
Use MouseTerm (and do make sure to install SIMBL first!) and scrolling will work like a charm, even remote, using Mac Terminal.
You need to fully quit the Terminal application (Command+Q) and then launch it again after installing MouseTerm.
This is an old question, but a top hit on google, so I feel compelled to provide an updated answer.
Running OSX El Capitan 10.11, vim mouse and trackpad scrolling just worked(TM) for me in Terminal.app by default. However occasionally the mouse/trackpad input stopped manipulating the vim buffer, and started scrolling the terminal buffer. The answer was Command+R or Menu View --> Allow Mouse Reporting. Turning that on allowed the mouse/trackpad scroll operations to move the cursor in vim.
Termanal Menu > View > Allow Mouse Reporting
Terminal Menu > Preferences >
Keyboard > Scroll alternate screen
If the mouse functionalities still do not work properly take a look at my answer in this post How to let vim behave on Mac OS X as on Ubuntu?, just add to your .vimrc
set ttymouse=xterm2
You can read this article, but I'm pretty sure since the default terminal in Mac OS X has a built-in scrollbar, the mousewheel commands automatically go to it. You could definitely use gVim as suggested in the previous answer. I find that I don't generally want to use the mouse in Vim though as it takes my hands off the keyboard.
I just use 50j to go down and 50k to go up. Not exactly scrolling, but it works pretty well.
Make sure the terminal is xterm & not ansi in Terminal Menu > Preferences > Profiles > Advanced. I accidentally broke scrolling by changing the term type in a naive effort to get coloring to work over ssh.
Use gVim, which gives you a text editing environment in a window you can scroll. Terminal is not involved when using gVim.
I'm using xterm in X11 (XQuartz 2.3.4) and vim works very fine with mouse and also suport 256 colors.
Here is the ~/.Xresources I use to make my xterm nicer in X11:
XTerm*faceName: Lucida Sans Typewriter Regular
XTerm*faceSize: 9
XTerm*utf8: 1
xterm*saveLines: 1000
xterm*jumpScroll: true
!xterm*awaitInput: true
!xterm*multiScroll: true
XTerm*scrollBar: false
xterm*scrollbar*thickness: 16
xterm*rightScrollBar: true
XTerm*foreground: white
XTerm*background: grey10
!XTerm*background: black
XTerm*cursorColor: yellow
xterm*visualBell: false
xterm*loginShell: true
Little tips, to remove the bell sound in X11's xterm type this command:
xset b 0
I would recommend using iTerm - it has so many advantages over Terminal eg Mouse support, 256 colors, sensible copy and paste (auto-copy, word/url selection with double click, middle click paste)...
When using iTerm create a .vimrc file (if not already there) in your home folder and add the line:
:set mouse=a
Scrolling down in vim to view a file works after this.

Unable to use X clipboard in Screen

I read the following code in Unix Power Tools on page 117
*VT100.Translations: #override\
Button1 <Btn3Down>: select-end(primary,CUT_BUFFER0,CLIPBOARD)\n\
!Shift <Btn2Up>: insert-selection(CLIPBOARD)\n\
~Shift ~Ctrl ~Meta <Btn2Up>: insert-selection(primary,CUT_BUFFER0)
I have not managed to see any effect of the above code.
How can you use X clipboard in Screen, without your mouse?
Using the mouse. Left-click drag to select and usually the middle mouse button pastes but some terminals may differ (PuTTY uses right-click). If you only have two buttons you click them both together (left mouse button + right mouse button).
In reply to comment below ("Can you do it without your mouse?"):
ctrl-insert : copy
shift-insert : paste
shift-delete : cut
shift-ctrl-C : copy
shift-ctrl-V : paste
Not all applications will support the last three (though Konsole does). In fact most console applications will not allow you to delete text once it's printed.
As far as selecting text without a mouse I'm not sure there's a generic mechanism for that. It's probably terminal and/or application specific (ie, vim has it's own keys for marking and copying text - but only within vim). You could do it with mouse emulation but I'm sure that would be a painful process.
You can't use the traditional Mac/Windows shortcuts in a terminal because they were reserved for different actions long before these OS existed (ie, Ctrl-C terminates the running process).
I'm trying to use Ctrl-C in X
X does not handle these operations directly, they are handled by the application. That's why modern GUI programs like Firefox or Gedit support Ctrl-C for copy but terminals and command-line programs generally do not. As I said, it's a conflict in established conventions and Ctrl-C for kill got in first.
BTW, you could do some key-remapping if it drives you nuts but then you would be learning bad habits when you use a different machine. Best to just get used to it or do most of your editing in a GUI application.
More Information
EDIT: For a Mac, this may help: MacOSX-to-Konsole or This or This. It looks like you need to replace Ctrl with Command on Mac keyboards. It seems like Terminal the mac console has a right-click context menu for copy-paste so to do it the traditional way you me need to install a different console program or change some settings in Terminal.

Resources