Posts Tagged ‘tmux’

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;
      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 »

let me first describe the problem that way annoying me for a long long long time.

i use tmux and do my compiling and coding in one window and then many a times i need to open a new window to do some other stuff. the problem i face is that the bash commands that i write in one window are not present in the new window’s bash history.

for example note a typical annoyance

cd code/genetic/convergence/zdt1/population100/

do some work and then create a new window in tmux (C-b c) in order to do some work in the same directory.

and now most probably you will be placed in your home folder if that is where you started tmux initially.  so now in the new window i have to do this long change directory command.  the long cd command will not be written to bash history unless the shell exits.

this was a major annoyance to me for a long time. i wanted all the bash sessions to share the history concurrently.  i found a hack which lets me do what i want.

put the following in your .bashrc

shopt -s histappend

If the histappend shell option is enabled the lines are appended to the history file, otherwise the history file is overwritten. to find out more about histappend just do a man bash and search for histappend.

the history command we refer to here is the bash built-in history command to know more about it do a

help history

yes that is help history **not** man history

if i have understood it correctly i guess the cleverness of the hack is in automatically doing a “history -a” after each command and what better way than to modify the PROMPT_COMMAND which defines how the prompt should be constructed each time. sweet 🙂

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 »


am having a lot of fun experimenting with archlinux and learning the proper way to approach linux … the arch philosophy.  so far i have had lots of fun learning various things about the way linux operates … the archwiki is a wonderful place to learn about so many things … the #archlinux irc channel on freenode is a great great place with wonderful ppl always ready to
help you and suggest the best practices to follow … while there is no need for me to write down the trivialities i m about to blog about (as they are already mentioned on the archwiki) but i will do it nonetheless as i have nothing
better to do at the moment … 😛

i m currently using openbox as a standalone window manager and am using the rxvt-unicode (urxvt) terminal program. in fact i m using the urxvt daemon (urxvtd) and simply launching the urxvt client (urxvtc) which attaches itself to the daemon. this greatly reduces memory requirement. i have a low end laptop IBM Thinkpad R51 (238MB ram/ 1.4GHz Pentium M processor) and i love to use firefox which means i must conserve as much memory as possible.

moving on to the central matter of this post now …

i had great difficulties in using urxvtc as i was used to gnome-terminal and its tabs. i was missing it greatly … so i set about searching for a tabbed terminal that was light on system resources. turns out that that urxvtc already was tab capable. there are two ways of using tabs in urxvt:

  1. urxvt -pe tabbed or urxvtperl
  2. urxvt-tabbed

approach 1:
to use urxvtperl simply add the following to your ~/.Xdefaults

URxvt.perl-ext-common: default, tabbed

that is it. the only problem i m facing right now is i do not know how to bring about the changes without having to restart my session. so like a fool all i do is log out and log in again. please let me know if you have a sensible solution to
bring in to effect changes made to .Xdefaults. anyways … now when you log in and launch urxvt/urxvtc you will see the following:

to open a new tab simply hit Shift+DownArrow and to move between tabs use Shift+LeftArrow and Shift+RightArrow. this works great but looks ugly in my opinion.

approach 2:
instead of changing the .Xdefaults you may also launch the tabbed version like this:

urxvtc -pe tabbed

now let us have a dekko at the urxvt-tabbed version which is gtk2 based.

urxvt-tabbed is installed automatically when you install urxvt … i installed urxvt as follows

sudo pacman -S rxvt-unicode-256color

that will also install the urxvt-tabbed version.

however when i launched urxvt-tabbed i got the following error:

Can’t locate Gtk2.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.10.1 /usr/share/perl5/site_perl/5.10.1 /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5/core_perl /usr/share/perl5/core_perl /usr/lib/perl5/current /usr/lib/perl5/site_perl/current .) at /usr/bin/urxvt-tabbed line 14.
BEGIN failed–compilation aborted at /usr/bin/urxvt-tabbed line 14.

turns out that i was missing gtk2-perl which is in the extra repo of arch so i did a

sudo pacman -S gtk2-perl

and that solved my problem with urxvt-tabbed which looks like this:

unfortunately i could not discover any keyboard shortcuts to create new tabs and move between them … 😦

so urxvtperl looks ugly but has keyboard shortcuts, urxvt-tabbed looks professional but is keyboard unfriendly … none of this really solves my problem …

so i presented my dilemma to the local gentoo guru, vivek who is taken aback and immediately retorts with:
“why do you need tabs? why don’t you use screen or tmux?”

hmmmm… this was interesting … why not indeed?

sudo pacman -S tmux

so the current set up i m using is as follows:

urxvtd -q -f in ~/.config/openbox/autostart.sh

urxvtc and then start a tmux session there

you r good to go!

the good thing about tmux over screen is that the info bar at the bottom is a great help … it also displays date and time which i was missing as i have no panels installed in openbox nor am i using conky.

p.s. i will try and arrange so that tmux automatically gets started when i launch urxvtc … but that is for later 🙂

remember that urxvt respects .Xdefaults NOT .Xresources.

  1. .Xdefaults
  2. urxvt
  3. tmux
  4. archlinux
  5. openbox

Read Full Post »