How to close the escape of the terminal in MacOS? - macos

when I paste the website address to the terminal, the terminal will escape the character.
eg:
I paste the http://stackoverflow.com/questions/ask?title=xxx ,
in the terminal, it will convert into http://stackoverflow.com/questions/ask\?title\=xxx
How to close the escape in MacOS terminal?
Thanks!

If you are asking how to paste into Terminal without escapes: from the menu bar, choose Edit > Paste (default shortcut: ⌘V).
You only get escaping if you use Edit > Paste Escaped Text (default shortcut: ⌃⌘V).
If your menu items have different keyboard shortcuts, you (or someone) has probably customized them using the Keyboard pane in System Preferences. It looks like this (although I haven't customized the Paste shortcuts):

Related

copy text from tmux inside VSCode

I use VSCode on macOS, I ssh into Linux remote station and here I run tmux (inside VSCode integrated terminal). However, I am not able to copy any text from tmux into system clipboard when used like this. I am not even able to select the text using mouse - when I select any the selection highlight disappears immediately.
The copying to system clipboard works if:
I run tmux inside separate window of iTerm2
I run normal zshell inside VSC integrated terminal
How to copy text from tmux inside VSC integrated terminal?
That is because vscode terminal does not support osc52. We gotta wait for this issue to be resolved https://github.com/xtermjs/xterm.js/issues/3260
OSC 52 (OSC stands for Operating System Command, a category of ANSI escape sequences which instruct the terminal emulator to perform certain actions) is a terminal sequence used to copy printed text into clipboard, without which copying from remote machine will not send the result to your local clipboard. Applications like tmux support it (actually, tmux is kinda forwarding it), iterm2 support it but not vscode
Solved using the mouse while holding Alt (Option) key. This way I can copy text from Tmux inside VSCode.

How to set terminal tabs titles in zsh, to vim filenames

I am using a oh-my-zsh shell in an Apple terminal (2.11) in full screen, and by default the name of the tabs is the name of the program being run (eg. vim).
Is there an easy way to set the title of the individual terminal tabs to the filename currently opened with vim?
The terminal window title is already set, but not visible in full screen mode. What I'm looking for is to get at a glance the title of all terminal tabs where vim is opened.
Screenshot below:
The solution seems to use vim script shared in https://stackoverflow.com/a/48975505/4756084. It sets the title dynamically based on what file is currently being viewed — which you cannot obtain by going into Terminal Preferences > Tab, and checking "Active process name" and "Arguments" (that would only display the name of the file opened when typing vim file.ext, ignoring any file opened with :e file2.txt, switches between vim panes, etc.)
(With oh-my-zsh, uncommenting DISABLE_AUTO_TITLE="true" in ~/.zshrc might help, as suggested in https://superuser.com/questions/292652/change-iterm2-window-and-tab-titles-in-zsh, although it seems optional after the step above.)

Open hyperlink file from iterm2 by Pycharm on MacOS

I would like to set up my iterm2 to open hyperlink file to pycharm on my mac. With default setting of iterm2, file is open by Xcode App and do some research online from this post open-file-on-intellij-from-iterm-2 and set up my iterm2 from Preferences/Profiles/Advanced/Semantic History -> Run command -> /usr/local/bin/charm \1 --line \2 or /Applications/PyCharm.app/Contents/MacOS/pycharm \1 --line \2. Neither of them works. How I can open file in Pycharm with a command + click in iterm2?
I was looking for the same thing in RubyMine. Turns out I just needed to associate .rb files with RubyMine in the Finder. No changes to iTerm config were needed.
Pick any .py file in Finder, and do Get Info (cmd-i) on the file. Under 'Open with:' pick PyCharm. You might have to first select 'Other...' and then you can pick PyCharm. Under that dropdown menu is a button that says 'Change All...', use that to associate all .py files, not just the one you initially selected.
Works like a charm (no pun intended) in RubyMine. The particular file I tried to open was already contained in a project that RM had opened, so it focused that project window, and opened that file.

copy paste in iterm, vim

I use iterm in Mac as my command line terminal. In iterm I use tmux as the terminal manager. When I open my code files in Vim copying has become painful in this. To copy text in vim I need to hold "option" key and then select the text. When holding option there are multiple issues:
1) I am unable to scroll while in select mode
2) When I split my terminal into 2 panes, select using option copies across panes making it tough.
I am not sure about the reason for this issue and where to find a workaround. Could anyone help me with it?
You cannot depend on iTerm's clipboard support because it will not know anything about Vim's or tmux's splits. Use native Vim copy instead.
:help v
:help V
:help y
:help d
:help "*
:help clipboard
So e.g. in order to copy two lines, you can do "*2yy (to clipboard register, two line yank); or you can mark something using visual mode, then just "*y (to clipboard register, yank). If you want the clipboard register to be always automatically used unless another register is specified, you can add the following to your .vimrc:
set clipboard+=unnamed
Then a simple 2yy will copy two lines, and you can just paste it in iTerm or any other application.

How do I copy and paste from bash to vim and vice-versa using only the keyboard?

Using this command:
http://www.hypexr.org/bash_tutorial.php#vi
I'm able to use vim commands in the bash. But, what I'd like to do is copy and paste from that (bash) into vim and vice-versa.
I know there are other posts on here using the middle mouse button, but I use putty to connect to linux boxes, and the middle mouse performs a selection, just like the left click drag.
I'm not looking for something that will modify my windows clipboard. Selecting in vim is useful for transfering stuff to and from windows, but I'd like a solution that will work both through putty and using a direct terminal.
Thanks in advance...
I use the copy&paste feature in screen. ctrl-[ to enter copy mode and ctrl-] to paste. There are different buffers and the ability to dump to a file. It's pretty powerful. The default is to copy lines, but you can curtail by columns join display lines into a single copied line (and other options). And since you would likely already be in screen when you run vim, you would have the paste buffer available. I also have hooks to copy the buffer to/from the X clipboard.
I don't know if that can help you, but I have installed a utility called xclip, which shares the X11 clipboard with VIM. I mainly use it to copy and paste between instances of VIM running in different terminal windows.
I typically use xclip with the following mappings, which keep a very similar behaviour to the usual yank and paste commands, but using the clipboard:
nmap `yy :.w !xclip<CR><CR>
vmap `y :w !xclip<CR><CR>
nmap `p :.r!xclip -o<CR>
nmap `P :.-r!xclip -o<CR>
Use the * (or + in X Windows) registers to reference the system clipboard. Anything yanked-to or pasted-from those registers can be used to cooperate with other applications:
Cut/Copy examples
"*yy : copy current line to the system clipbard
gg"*yG : copy current file to the system clipbard
"*dd : cut current line to the system clipbard
etc, etc
Paste examples
"*p : paste the system clipbard
Or in insert mode:
i Ctrl+r *
Or
i Ctrl+r Ctrl+p *
(the last one pastes withouth formatting, useful to avoid those ugly pastes from the OS clipboard where each indented line appears more and more shifted)
You can copy from/to the clipboard in both vim and bash using ctrl + ins for copy, and shift + ins for paste.

Resources