Back to Blog
Putty paste in terminal6/19/2023 You can also provide numerical arguments to copy the last-nth command. A Custom Functionĭeveloping on the quick solution,here is a small function I wrote which is pretty smart and will copy the last used command. Just run this command and it will copy the command you just ran to the clipboard.īasically, what it does is that it prints your command history and takes the second last command and feeds it to your clipboard (the last command is this itself, so it selects the second last command). history | tail -2 | head -1 | xclip -selection clipboard If you now hit Up you can run it on the new has suggested a good solution but it breaks often. Now when you run a long command line, you can switch to another terminal and hit return (just to run $PROMT_COMMAND, alternatively, open a new terminal window) and it will be accessible to this terminal's history. This means that every command you run will be immediately written to the history file. How to do that ps: I am using putty So, I open a vim window via putty. That's, I copy something to clipboard in my local host and want to paste it to the vim in the remote host. I meet a trouble when I try to paste something to vim. history -a will write the history of the current session to the history file and history -r will reload that file. 80 I am using putty to connect a remote host and editing via vim. If it is set the value is executed as a command before issuing a new prompt. PROMPT_COMMAND is a special bash variable. Add this line to your ~/.bashrc: PROMPT_COMMAND='history -a history -r' You can also save commands across terminals using bash's history. You can paste into the same terminal, simply by killing (cutting) the command with Ctrl K and then pasting with Ctrl Y. When you let go of the button, the text is automatically copied to the clipboard. In order to copy text to the clipboard, you just click the left mouse button in the terminal window, and drag to select text. You can paste into another terminal by running: $ xclip -o PuTTYs copy and paste works entirely with the mouse. If you want to paste without using a mouse, it will depend on where you are pasting. You now have "This is a long command line" in your middle click clipboard. Type Ctrl A to go to the beginning of the line, enclose the command in quotes then echo it: $ echo -e "This is a long command line" |xclip For example : $ This is a long command line Unfortunately, this won't work in your mysql environment (it has its own buffer for copied lines) but it will if you want to run a 'normal' command. Once you have installed it, you can use it to connect to your X clipboard. Xclip - command line interface to X selections (clip‐ You can do this using a program like xclip: NAME
0 Comments
Read More
Leave a Reply. |