Ubuntu - change tmux 1.8 to tmux-next 1.9 [closed] - tmux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
After I tried install few plugins for tmux I found that my tmux version is 1.8.
Following steps from this answer I install tmux 2.1: Ugrade tmux from 1.8 to 1.9 on Ubuntu 14.04
(I didn't found tmux=1.9a-1~ppa1~t and instead install tmux-next and substitute link in usr bin with sudo ln -sf $(which tmux-next) /usr/bin/tmux
Tmux works nicely, but didn't load my config. I tried tmux source, but now I should tmux source every time I use tmux.
And after all I get this errors:
unknown option: mode-mouse
unknown option: mode-mouse
unknown option: mouse-select-pane
unknown option: mouse-resize-pane
unknown option: mouse-select-window
unknown option: mode-mouse
unknown option: mode-mouse
Is tmux-next the same tmux? And what I should do to load .tmux.conf automatically?

Just have installed tmux 2.1 on Ubuntu Server and faced the same problem. The solution for me is to delete all those unknown options and add those lines instead:
set -g mouse-utf8 on
set -g mouse on
Now in tmux 2.1 I can choose a pane, a window and resize everything with a mouse as it was in tmux 1.8
MOUSE SUPPORT section of 'man tmux':
"The default key bindings allow the mouse to be used to select and resize panes, to copy text and to change window using the status line. These take effect if the mouse option is turned on."
UPDATE (since there are a lot of questions):
0 Install:
brew cask install easysimbl
1 Download .dmg file here: https://bitheap.org/mouseterm/
2 Execute:
cd /Volumes/MouseTerm && cp -r MouseTerm.bundle /Library/Application\ Support/SIMBL/Plugins
3 Add this to your .tmux.conf file:
set -g mouse-utf8 on
set -g mouse on
bind -n WheelUpPane select-pane -t= \; copy-mode -e \; send-keys -M
bind -n WheelDownPane select-pane -t= \; send-keys -M
4 Reload tmux
5 Scroll!!!1
I hope this will help. Works for me on iTerm 2/OS X El Capitan/tmux-2.1

Options mode-mouse, mouse-select-pane, mouse-resize-pane, mouse-select-window are deprecated. Use mouse option instead, it covers all the functionality of those four options:
set -g mouse on
The official deprecation dates back to v2.1, but the actual changes were introduced between v1.9 and v2.0.

Related

Configure tmux copy mode to also dump a copy into the system clipboard

When working with multiple panes, it's convenient to use the tmux copy mode (ctrl+b [) to be able to use pane-aware copying. However, copy mode copies into a tmux copy buffer, rather than into the system clipboard. Ideally, I would like a copy to automatically copy into the system clipboard too.
A basic starting point was to add this alias to my bashrc:
alias tmux2clip='tmux save-buffer - | xsel -i -b' (on linux, requires xsel to be installed)
alias tmux2clip='tmux save-buffer - | pbcopy' (on macos)
After I copy using copy mode, I run the alias and the text gets copied into my clipboard! Works like a charm, but always requires that one extra manual step.
It would be ideal, if that alias can trigger as a kind of "post tmux copy hook" that I configure in tmux.
The best thing I could come up with is this line in my ~/.tmux.conf:
bind-key -T copy-mode MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xsel -i -b"
# similarly, I believe only needed for keyboard based copies:
bind-key -T copy-mode C-w send-keys -X copy-pipe-and-cancel "xsel -i -b"
bind-key -T copy-mode M-w send-keys -X copy-pipe-and-cancel "xsel -i -b"
This causes any mouse based selection (note: I prefer mouse selection over keyboard based selections) to trigger a copy of that selection into my system clipboard. The annoying thing is though, that it will always happen, i.e. not only in copy mode, just anytime I select something it happens. This turns out to be quite sensitive in practice, just clicking the window with my mouse to give it focus often already accidentally triggers a small selection (often accidentally overwriting existing content in my clipboard, causing me to sometimes paste completely different stuff than intended).
I searched many similar questions but haven't been able to find any satisfying answers. I would really hope to find a way to get a kind of "post tmux copy hook" where I can insert my copy-to-clipboard command.
I use Ubuntu 18.04, with tmux 2.6. Please also be aware that I use mouse mode in my ~/.tmux.conf:
set -g mouse on
Any help would be highly appreciated. I've been wanting this for many months now already, and all of my revived efforts have only led to lost time :(
If you don't want tmux to enter copy mode when you drag on the pane, then unbind MouseDrag1Pane in the root table (unbind -n MouseDrag1Pane).

Different starting directory per window?

I daily use tmux (2.5) on my laptop to work, and my tmux sessions have a starting directory which is the working directory I started the tmux session from. Every pane/window I open start with this starting directory as working directory.
I can change this starting directory, and this change would apply to the whole session.
But if I want to work on a different project with several panes, I could start a new window, but every pane I would open in it would start with the session's starting directory : I would have to cd to the new location for each pane which isn't practical.
If I need to work on several project/directories simultaneously, I can start a new terminal session, then cd to the relevant directory/project and start a new tmux session. That's not complicated.
But if I want to do the same thing on a server through ssh, I'd need to either :
open a new ssh session.
either embed my remote tmux sessions in an other tmux session.
Neither sounds practical to me, I'd prefer a single tmux session on the remote machine.
I think it would be more convenient to being able to start new window with its own starting directory location that would apply to any new pane opened in it. Is there a way to achieve this?
Edit :
I already tried the -c parameter of tmux new-window command.
But it doesn't assign its starting directory to the window created this way, it only applies this custom starting directory to the first pane created.
Any new pane opened in this window then uses the session's starting directory as default working dir (and not the path passed to tmux new-window).
This question is very similar to: https://unix.stackexchange.com/questions/12032/create-new-window-with-current-directory-in-tmux
It depends on your tmux version but the -c parameter does do the trick but it does not remember the setting. There used to be a default-path setting but that has been removed in version 1.9 unfortunately.
For newer versions you will need to pass along the -c in all cases (you can use an alias if you manually execute that command) or if you use key bindings you need to rebind the split/new window keys.
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
To use a custom path instead of the current pane path, execute this command:
tmux setenv custom_path /home/whatever/some/path
Put this in your config:
bind '"' split-window -c "#{custom_path}"
bind % split-window -h -c "#{custom_path}"
bind c new-window -c "#{custom_path}"
Yes, it turns out the -c option to the new-window command is what you are looking for: https://unix.stackexchange.com/questions/12032/create-new-window-with-current-directory-in-tmux Also, this: https://unix.stackexchange.com/questions/101949/new-tmux-panes-go-to-the-same-directory-as-the-current-pane-new-tmux-windows-go
So either of tmux new-window -c $(pwd) or tmux new-window -c /path/to/dir inside your tmux session should do it.

Tmux window or pane name won't change in GNOME Terminal

Using Fedora 25 and GNOME Terminal. I have used Tmux for a few years in Ubuntu with a long customized .tmux.conf file. Recently installed Tmux and Tmuxinator in Fedora.
When I open the Terminal. I see that the title is set to tom#localhost:~. When I create a new Tmux session such as tmux new -s panes. The title of the pane is still tom#localhost:~.
Inside the Tmux session. When I open a new window with name console like this new-window -n console. The title won't change to console and keeps saying tom#localhost:~.
I thought maybe tmux is not overriding the titles so I added this to the tmux.conf file:
set-option -g set-titles on
set -g terminal-overrides "xterm*:XT:smcup#:rmcup#"
That still doesn't do anything.
The Terminal settings. I have Profile/Command/When terminal commands set their own titles set to Replace initial title.
I cannot figure this out. What am I doing wrong here?
I am not exactly sure why it works. But this solves my problem.
Inside the .tmux.conf file I added the line set-option -g allow-rename off. At the top of the file I had the line set -g default -terminal "xterm". I removed this line.

Tmux: unknown option: c0-change-interval

I have compiled tmux 1.9a and added the following to my tmux.conf file:
setw -g c0-change-interval 50
setw -g c0-change-trigger 75
However, this doesn't seem to work (I get some messages at startup that say they're unknown options). When I type setw -g c0-change-trigger 75 into tmux directly, I get:
unknown option: c0-change-interval
when I run tmux -V I get tmux 1.9a. My thinking is that the alias for the tmux PATH is set after I load tmux, and I'm actually running tmux 1.6, but I'm not aware of any way of checking what version of tmux is actually running.
When I run ps -u under COMMAND it just says tmux -2 new. Here is the relevant contents of my .bashrc file:
# this is where the compiled version of tmux 1.9a is:
export PATH="/home/quant/bin:$PATH"
# tmux
# If not running interactively, do not do anything
[[ $- != *i* ]] && return
[[ -z "$TMUX" ]] && exec tmux
What is going on? As far as I know the c0-change-interval command is supported by tmux 1.9a, and this is what I seem to be running.
This isn't the original poster's problem but if anyone is coming up on this now the problem is actually that c0-change-interval and c0-change-trigger have been removed completely.
From: https://raw.githubusercontent.com/tmux/tmux/master/CHANGES
"The c0-* options for rate-limiting have been removed. Instead, a backoff
approach is used."
So you should remove them from your configuration.
My thoughts:
make install doesn't tell your package manager about installed files so
I think there's a problem/conflict with your distribution package and your build :
1) check tmux package in your package-manger or synaptic & delete it & go to tmux build folder run make uninstall & install it again .
Or
2) for a better building process , build deb/rpm/.. packages is the best as it'll tell you package manager so replace the old version with a tool like checkinstall that will be easy,
instead of :
./configure && make
sudo make install
do :
./configure && make
sudo checkinstall
in my case ubuntu 14.04 that make my day happy,(I don't remember if I configureed some options, whatever)

"tmux set -g mouse-mode on" not scrolling

To allow scrolling a tmux pane with a mouse, I put the following in my ~/.tmux.conf file:
set -g mouse-mode on
However, nothing changes. When I scroll, it still scrolls outside of tmux. Why is this?
So this option has been renamed in version 2.1 (18 October 2015)
From the changelog:
Mouse-mode has been rewritten. There's now no longer options for:
- mouse-resize-pane
- mouse-select-pane
- mouse-select-window
- mode-mouse
Instead there is just one option: 'mouse' which turns on mouse support
So this is what I'm using now in my .tmux.conf file
set -g mouse on
As #Graham42 noted, mouse option has changed in version 2.1. Scrolling now requires for you to enter copy mode first. To enable scrolling almost identical to how it was before 2.1 add following to your .tmux.conf.
set-option -g mouse on
# make scrolling with wheels work
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'"
bind -n WheelDownPane select-pane -t= \; send-keys -M
This will enable scrolling on hover over a pane and you will be able to scroll that pane line by line.
Source: https://groups.google.com/d/msg/tmux-users/TRwPgEOVqho/Ck_oth_SDgAJ
Just a quick heads-up to anyone else who is losing their mind right now:
https://github.com/tmux/tmux/blob/310f0a960ca64fa3809545badc629c0c166c6cd2/CHANGES#L12
So that's just
:setw -g mouse
this should work:
setw -g mode-mouse on
then resource then config file
tmux source-file ~/.tmux.conf
or kill the server
Paste here in ~/.tmux.conf
set -g mouse on
and run on terminal
tmux source-file ~/.tmux.conf
As #Graham42 said, from version 2.1 mouse options has been renamed but you can use the mouse with any version of tmux adding this to your ~/.tmux.conf:
Bash shells:
is_pre_2_1="[[ $(tmux -V | cut -d' ' -f2) < 2.1 ]] && echo true || echo false"
if-shell "$is_pre_2_1" "setw -g mode-mouse on; set -g mouse-resize-pane on;\
set -g mouse-select-pane on; set -g mouse-select-window on" "set -g mouse on"
Sh (Bourne shell) shells:
is_pre_2_1="tmux -V | cut -d' ' -f2 | awk '{print ($0 < 2.1) ? "true" : "false"}'"
if-shell "$is_pre_2_1" "setw -g mode-mouse on; set -g mouse-resize-pane on;\
set -g mouse-select-pane on; set -g mouse-select-window on" "set -g mouse on"
Hope this helps
You can still using the devil logic of setting options depending on your current Tmux version: see my previous answer.
But since Tmux v1.7, set-option adds "-q" to silence errors and not print out anything (see changelog).
I recommend to use this feature, it's more readable and easily expandable.
Add this to your ~/.tmux.conf:
# from v2.1
set -gq mouse on
# before v2.1
set -gq mode-mouse on
set -gq mouse-resize-pane on
set -gq mouse-select-pane on
set -gq mouse-select-window on
Restar tmux or source-file your new .tmux.conf
Side note: I'm open to remove my old answer if people prefer this one
This line:
set -g mouse-mode on
in your ~/.tmux.conf file won't work.
For one thing, the proper setting is not mouse-mode, but mode-mouse.
Second, it only works on older versions of tmux (pre-version 2; you can run tmux -V to see what version you have, but you can also run man tmux to see if mode-mouse is a supported option).
And third, technically man tmux says to use the mode-mouse option with setw (set-window-option) and not with set (set-option), although I've seen it work with set (as well as setw).
These lines should work:
If your version of tmux is recent enough (that is, if tmux -V shows version 2 or newer), you can put this line in your ~/.tmux.conf file:
set-option -g mouse on
But if you use an older version of tmux, put these lines in your ~/.tmux.conf file:
set-window-option -g mode-mouse on
set-option -g mouse-resize-pane on
set-option -g mouse-select-pane on
set-option -g mouse-select-window on
Again, if you're not absolutely sure which line(s) to put in your ~/.tmux.conf file, run man tmux and search for mouse-mode, mouse-resize-pane, mouse-select-pane, and/or mouse-select-window. If you find them, then use those options (the ones for the older version of tmux).
Putting these lines in will allow you to use the mouse scroll wheel, it will allow you click on various panes to activate them, and it will allow you to resize panes just by clicking-and-dragging on their splitter separator.
You can also copy-and-paste using your mouse. However, you may notice that copying-and-pasting with your mouse may not work like it normally does on your console. To work around this, I've noticed that holding down the SHIFT key while using your mouse's copy/paste abilities makes them work normally again. (On MacOS, fn seems to work for me better than SHIFT.) Or you can learn tmux's approach to copy-and-pasting (which I do recommend).
A note on using tmux's native ability to copy/select/paste:
Personally, I feel that the vi keys make more sense to me than the default emacs keys (for example, it feels more natural to exit selection mode with vi mode's ENTER than with emacs mode's CTRL+w or ALT+w), so I have this in my ~/.tmux.conf file:
# For vi-like keys in copy/paste/selection mode:
set-window-option -g mode-keys vi
However, I've noticed that on older versions on tmux, this line won't work, unless I've also included the line:
set-window-option -g mode-mouse on
Good to know: Occasionally, when you're using the mouse's scroll wheel, you'll discover that your pane/screen appears to be frozen or locked up (it won't respond to keyboard input), and it's not clear what to do to unlock it.
It's not locked up. You're likely in tmux's selection mode. To get out of it, try one of these:
Hit ENTER. (Will likely work in vi mode.)
Hit ALT+w. (Will likely work in emacs mode.)
Hit CTRL+w. (Will likely work in emacs mode.)
Hit META+w. (Will likely work in emacs mode.)
Hit Esc. (Will likely work in emacs mode.)
Hit q. (Will likely work in vi mode, and may work in emacs mode as well.)
Ultimately, you can try hitting:
CTRL+w     ENTER
or:
Esc     q
Chances are, that will put you back in the normal mode where your keyboard is responsive again.
Using the mouse with vim:
I've discovered that putting this line in my ~/.vimrc file:
:set mouse=a
seems to work well with tmux, better than this line:
:set mouse=r
I can't really explain the difference; if you're a vim user, try them out and see which setting works best for you.
If you need to test out these tmux options, you may find yourself editing your ~/.tmux.conf file, exiting tmux, and then restarting tmux. This can become a tedious process, so if you want some work-arounds, here are some options:
Option1: After editing (and saving) your ~/.tmux.conf file, run this command (while in tmux):
CTRL+B :source-file ~/.tmux.conf ENTER
This will immediately apply the new settings in your ~/.tmux.conf file into your current tmux session, without the need to restart tmux.
Option 2: If you're in a tmux session, you can turn on/off options temporarily just for that session by running commands like these at the Unix shell prompt:
tmux set-option -g mouse on
tmux set-window-option -g mode-keys vi
Option 3: You can also temporarily turn on/off options in a tmux session with:
CTRL+B :set-option -g mouse on ENTER
CTRL+B :set-window-option -g mode-keys vi ENTER
Good luck, and have fun using tmux !
Try this. It works on my computer.
set -g mouse on
Ctrl + B and then set mouse. -g is not needed anymore.

Resources