Where is the tmux command for choose-window? - tmux

Learning tmux and one of the first things the book tells you to find in the key bindings (ctrl+b ?) using (ctrl+s) is 'choose-window' but that doesn't exist. There is a choose-tree (2 actually [ctrl+b + w] or [ctrl+b + s]). I cannot find anywhere that differentiates these or explains that one replaces choose-window even though ctrl+b+w seems to operate as choose-window. Can anyone confirm or refute this?

choose-window was replaced by choose-tree in version 2.6.
Now, instead of showing all panes from the current session it shows a tree view of all panes in all sessions.
To get the old behavior you can put this in your .tmux.conf:
bind-key w run-shell 'tmux choose-tree -Nwf"##{==:##{session_name},#{session_name}}"'
(taken from https://github.com/tmux/tmux/issues/1115)

Related

How to map Ctrl+Shift+<key> in Neovim + Tmux in Alacritty

I use neovim with tmux in alacritty and I'm currently tring to create keymaps to the combinations <C-S-h> and <C-S-l> (<S-h> and <S-l> are already mapped), but I can't get it to work when running tmux.
I've already followed this tutorial, but it only works outside of tmux. Is there some extra tmux configuration that I need to do in order to make this work?
I had the same behavior as you and got it to work both inside and outside tmux by changing the '5u' in chars to '6u' (7u and up did not work).

Can the number of sleeping task in the current window be shown in Tmux statusbar?

I often use ^Z to make sleep a process, possibly open a new one, make this one sleep too, and so on, also moving between different Tmux windows.
So what I would like, is that the Tmux status bar update relevantly to indicate me how many processes are sleeping in the currently focused window.
Is that possible?
This is a common question - how to pass information from a shell inside tmux to tmux. The easiest way to do this is to have your shell do it as part of PS1 or some other variable that is evaluated when the prompt is printed.
There are two things you can do:
1) Set a user option with tmux set -w #myoption xyz, then you can use it in the status line with #{#myoption}. This has the disadvantage that it cannot work over ssh.
2) Set the pane title using the escape sequence, for example: printf "\033]2;xyz\033\\". It is then available in #{pane_title}. This works over ssh but had the disadvantage that there is no way to prevent applications also changing the title if they want.
In either case you will only want to run this when TMUX is set, so something like:
[ -n "$TMUX" ] && tmux set -w #myoption $(jobs|wc -l)

Start tmux with specific layout

I have a question and searched on the web but didn't find a specific solution, or solutions didn't work for me.
In order to start tmux with a specific layout of panes, I'd like to setup my tmux.conf accordingly.
Now, I found something like this:
new -s my_sess # create new session
neww -n shell # create new window
splitw -v
Which has no effect, since I see only one window, not split into panes. Another trial was like this:
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
# Split the pane horizontally
splitw -h
Which results in an error no current target.
It's probably a stupid mistake of mine caused by poor understanding. But I hope that people here might be able to help.
I'd say that this very basic task is covered abominably in the available tmux resources.
It cost me six hours of perusing material to come to a solution. The biggest help came from https://gist.github.com/sdondley/b01cc5bb1169c8c83401e438a652b84e
Your minimal .tmux.conf file shall be (you got there 99%):
new -s my_sess # create new session
neww -n shell # create new window
split-window -t shell # split vertically the window just created
and you have to launch it with tmux attach instead of a plain tmux.
I have created a gist to sum up my experiences. It covers also topics like launching different commands in each new pane.
If you create new sessions in .tmux.conf, you probably want to start tmux with tmux attach not tmux new. If you don't, you will be creating both your session in .tmux.conf and a new session, which is probably not what you want. Your first attempt looks OK, so I guess this is what you are doing.
Also remember .tmux.conf is only loaded on server startup, so only the first time you run tmux. If you want to create a new session like this later, put it in a separate config file and load it with source-file.

OS X: How do I use the tmux prefix correctly?

I am following a tmux tutorial which states (Control + b) + % should open a new pane. When I try to do this from tmux though, the Control + b keypress just gets converted into a character which displays on the command line.
Various tmux tutorials seem to treat Control + b as a special keypress, but it always just appears as a character on my command line. How do I use the tmux prefix correctly?
That tutorial you linked to in your question has you overriding the default Control-b with Control-a
try (Control-a) + %
this is a popular override. I use it. My ~/.tmux.conf has:
set -g prefix C-a
unbind C-b
bind C-a send-prefix
this is nice when you also remap your caps lock key to be control, the caps lock key and the 'a' key are right next to each other

tmux changed keybinding (resizep) not working as expected

I use vim, and so I wanted to change a couple of tmux's default bindings. In particular I wanted to change the resizing commands so that e.g. ctrl-b ctrl-k resize the split up by one position. I entered the following into my .tmux.conf:
bind-key C-k resizep -U
and it works, except that it only allows me to resize by one unit at a time before I have to hit ctrl again. In other words, I can't hold down ctrl and press b followed by k a bunch of times (while still holding down ctrl), whereas I can hold down ctrl, press b, and then press the up arrow key a bunch of times.
Does anyone know exactly why this is, or how I might replicate my desired behavior?
You need to specify the -r parameter in your command:
bind-key -r C-k resizep -U
As explained in tmux man page:
bind-key [-cnr] [-t mode-table] key command [arguments]
(alias: bind)
Bind key key to command. By default (without -t) the primary
key bindings are modified (those normally activated with the
prefix key); in this case, if -n is specified, it is not necesā€
sary to use the prefix key, command is bound to key alone. The
-r flag indicates this key may repeat, see the repeat-time
option.

Resources