Pasting into OS X command line adds extraneous characters - macos

When I paste text into the Terminal window, Terminal appends 0~ before the pasted string and 1~ after it. I've never seen this behaviour before. If I copy foo from anywhere (including the same Terminal window), pasting into the command line results in:
-bash-4.2$ 0~foo1~
I tried every method for pasting text into OS X terminal from How to paste into a terminal?, i.,e.
Command v; CommandControlv; Shift + Insert.
Pasting into text editors and browsers (basically, any place other than Terminal) does not add any extra characters. Why is this happening and how can I fix it?
I'm using macOS 10.14.2; Terminal version 2.9.1.

I don't know the actual answer for this but for me it works after restarting the terminal.
Command + Q
I will update once I will find something.

Related

Print terminal command output directly into vim - macOS

Whenever I enter a terminal command in vim (e.g., !echo hello), I am momentarily kicked out to view the result of that terminal command and then prompted with Press ENTER or type command to continue. This is a bit jarring. I would like to stay within vim and with the command output printed out at the bottom.
I know vim :read will take the terminal output and actually put it into my buffer, but that is not what I am looking to do. Here is some reading if you are interested in a tangent.
It looks like when I run vim in Screen I get what I am looking for, but I am trying to get this to work with tmux and the stock Mac terminal.
After a ton of research, probably too much, I got it! It looks like vim will send commands to the terminal, which in turn defines the behavior of how the terminal commands are processed from vim. Put this into your .vimrc file:
set t_ti= t_te= " show results from terminal commands within vim!
From what I understand, this just makes sure to send nothing to the terminal, which yields my desired results!
Side note: the above addition to your .vimrc file will also prevent the vim buffer from clearing when exiting vim (e.g., :wq). I am okay with this! It is kind of nice sometimes to see what you were just working on :).

Why is a [ being added to my prompt after upgrading to OS X 10.11?

Since upgrading from OS X 10.10 to 10.11, my Bash prompt has started to behave strangely. A configuration that I've been using for years without issues and started adding a [, on the line above the current line. That is, if I have
~/dir $ cd foo
and hit return, I get
[~/dir $ cd foo
~/dir/foo $
or, if I just have
~/dir $
and hit return, I get
[~/dir $
~/dir $
I get the same behavior regardless of the command I enter (or if, as above, I enter none).
Even if I completely empty my .bash_profile I still get this behavior.
What can I do to fix this (and why might this suddenly have started happening as the result of the upgrade to El Capitan)?
It is not about the bash setting or any other bash config file. You just need to uncheck "Automatically Mark Prompt Lines" option in Edit menu of Terminal app.
The new Marks feature in El Capitan 10.11 adds structure to the terminal contents by marking prompt lines and other interesting content, enabling operations like navigating, selecting, Copying, Printing and deleting commands or their output.
You can hide the marks if you don't want to see them, with the View > Hide/Show Marks menu item.
It should be rare that someone actually needs to turn off automatic marking of prompt lines, since, other than their visual representation—which you can turn off—they are passive and only affect the new Marks-related commands. The Edit > Marks > Automatically Mark Prompt Lines menu item—which is a persistent preference—exists primarily in case you want to have complete manual control over which lines are marked, by using the other commands in the Marks submenu.
A very good explanation of what you can do with Marks and the related commands is found in this answer to this question.

Meteor Shell overwriting previous input

Typing approximately 60 characters causes the cursor to jump back to the start of the same line, overwriting previously input text...
Tested in both ComEmu & default Command Line using Windows 7 64-bit so appears to be a Meteor issue
Is there something I can do to fix this?
This has nothing to do with meteor shell. This is caused by your terminal. You can just keep typing and meteor shell will still execute the right command (as you typed it, not as you see it) when you hit enter.
Example:
> var x = [1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3m,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10];
> x.length
320

vim: setting mouse cursor, line number and clipboard copy without line numbers all at once

I use vim for all my coding and was wondering to use the following features but getting troubles in configuring my .vimrc file
using mouse pointer for cursor : set mouse=a (works perfectly)
using line numbers : set number (works perfectly)
copy to clipboard : does not work as expected.
Reason: because " set mouse=a " keeps it into visual mode.
Workaround : press and hold shift and then select the text : works OK
Problem : because I press shift and hold it, the line numbers are also getting copied to the clipboard and
pasting it wont be of help as those line numbers need to be removed. ofcourse i can unset it and remove line numbering temporarily, but i dont want to do it for every file i open.
So I need :
mouse support for cursor
line number support
copy to clipboard (without) line numbers
any solutions ? (I did try a combination of this and that from other questions, but couldnt get it done)
On ubuntu, run this command in a terminal to install a proper Vim:
$ sudo apt-get update && apt-get install vim-gnome
On Suse, look for the "gvim" package.
Once you are done, you can use "+y to yank to your system clipboard and "+p to paste from it.
Getting the clipboard to work in VIM works different in different Operating Systems. In my vimrc, I have it set up for OSX and Linux and it works nicely in both. In Linux I can just yank lines and they will be in the clipboard, on the Mac when I use MacVim I can use CMD+C (works out of the box) or when run in the console, I use c.
This is the required vimrc setup. When running Linux, you can of course just use the last two lines. When running Windows and using GVim, CTRL+c should work out of the box, as well.
"Clipboard
if os == "darwin"
"Fast copying to clipboard in visual mode
vmap <leader>c "*y<cr>
"Fast cutting to clipboard in visual mode
vmap <leader>x "*x<cr>
elseif os == "Linux"
set clipboard=unnamed
set clipboard=unnamedplus
endif

newline in mac command file created in windows

I am creating a command file in windows using JavaScript activexobject.
This file will run on Mac after double click.
I am writing the file as
script.write("#!/bin/bash\r");
script.write('cd "$(dirname "$0")"\r');
The additional \r is for carriage return line ending in Mac.
But this doesn't work. The command doesn't execute just starts and over. No cd happens.
I am sure that this problem is related to line endings because when I edit the line ending (by deleting the newline and again add newline using return key) after opening the command file in Mac with TextEdit, it works.
How can I solve this in write method?
You should try writing '\n' instead of '\r'. Carriage returns were used in pre OSX machines only.
If you wanna visually see the line endings you could open up vim on the Mac and type :set list. All new lines will appear like $ and carriage returns as ^M. You should only be seeing $ if this is an OSX machine.

Resources