Feeds:
Posts
Comments

Archive for the ‘tmux’ Category

can’t select text with mouse.

problem at hand: how do i use the mouse to copy/paste text in xterm running tmux on PC? normally you should not have problems selecting text and pasting it with your mouse. everybody knows about left clicking and then dragging to select and copy the text. in order to paste you need to middle click your mouse. however there are certain options which if set will prevent this functionality. if you have set the following options

  • mouse-select-pane
  • mouse-select-window

you will notice that you are not able to select text at all.

the solution is to use the shift key.

hold down the shift key and then left click and drag across the target text. if you want to now paste the selected text back in to xterm, you must also hold down the shift key and then middle click in order to paste the text. this is not mentioned in the tmux man pages so i do not think this is a tmux feature. guess this has something to do with xterm, but i m not sure.

xterm version 278-1

tmux version 1.6-2

archlinux PC

guly in the comments informs me that iterm users on macosx need to use the option key. bruceedge pointed out that if the target text area resides in a pane of a split window then trying to copy with this method will also copy stuff from adjacent panes. to counter this problem one hack is to use the zoom pane functionality. say you want select text from a pane that resides in a split window with other panes. with keyboard focus on the target pane, you simply hit prefix + z to maximize this pane to the entire window. copy what ever it is you want to copy and then hit prefix + z again to toggle back to the previous state.

Read Full Post »

guys when i run a code i get a lot of text dump on the console so i m in the habbit of issuing

“tmux clearhist && ./a.out”

so that when i scroll back i only see dump pertaining to only the current execution of a.out . turns out that this interacts weirdly with the standard input buffer. for a simple code such as the follows:

#include <iostream>
#include <string>
int main()
{
  std::string s;
  while(std::getline(std::cin,s))
    {
      std::cout << s << std::endl;
    }
return 0;
}

does not work at all with “tmux clearhist && ./a.out”.

by “does not work” i mean the program does not wait for any input and simply proceeds to completion. at first i thought that probably the standard input buffer has whitespaces or newlines sitting which i needed to clear before doing an input, but that did not work either.

so currently i have resorted to first clearing up history and then running my executable instead of chaining them together as one code. or one can use

tmux clearhist >/dev/null 2>&1 </dev/null && ./a.out

Read Full Post »

copy paste in tmux

i m assuming that the tmux prefix is Control+b and that you have emacs style key bindings on

1) enter copy mode using Control+b [
2) navigate to beginning of text, you want to select and hit Control+Space
3) move around using arrow keys to select region
4) when you reach end of region simply hit Alt+w to copy the region
5) now Control+b ] will paste the selection

you can navigate the text using the emacs style navigation key
Control+p, Control+n, Control+f, Control+b etc.

Dan in the comments informs me that if you have vi style key bindings on then the following applies:

1) enter copy mode using Control+b [
2) navigate to beginning of text, you want to select and hit Space
3) move around using arrow keys to select region
4) when you reach end of region simply hit Enter to copy the region
5) now Control+b ] will paste the selection

To enable vi like cursor movement in copy mode put the following in your ~/.tmux.conf:


set-window-option -g mode-keys vi

more over what ever you copy, you may dump that out in your terminal using


tmux show-buffer

and even save to a file(say, foo.txt) using


tmux save-buffer foo.txt

To see all the paste buffers try Control + b #. To dump out the varios buffers on to the terminal or file you may use

tmux list-buffers
tmux show-buffer -b n
tmux save-buffer -b n foo.txt

where n is the index of the paste buffer.

Read Full Post »