I try make a bind-key for tmux with two keys, like
bind-key Vs split-window "command00"
I try with this in my ~/.tmux.conf
bind-key V split-window "~/.tmux/tmux-v.sh"
and this script tmux-v.sh
#!/bin/bash
read -n 1 input
case $input in
s ) tmux split-window 'vim +VimShell' ;;
S ) tmux new-window 'vim +VimShell' ;;
* ) tmux new-window "vim" ;;
esac
this work, but this solution split the window.
I try with command-prompt and run-shell but is necessary press ENTER
any suggestion ?
Try this:
bind V send-keys "~/.tmux/tmux-v.sh" \; send-keys "Enter"
Related
The version I am running is tmux 3.3a
I cannot copy text to my clipboard when i scroll up in a terminal session. This seems to be because the text i'm highlightning is yellow in color rather than clear. I cannot scroll up in my tmux history and copy text to my clipboard with fn + cmd+c.
If I do not scroll the tmux session, copying to my clipboard works correctly when i press fn + cmd+c.
Here is an image that shows text that I cannot copy to my clipboard with fn + cmd+c.
Here is my tmux.conf
set -g mouse on
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
bind -n C-WheelUpPane select-pane -t= \; copy-mode -e \; send-keys -M
bind -T copy-mode-vi C-WheelUpPane send-keys -X halfpage-up
bind -T copy-mode-vi C-WheelDownPane send-keys -X halfpage-down
bind -T copy-mode-emacs C-WheelUpPane send-keys -X halfpage-up
bind -T copy-mode-emacs C-WheelDownPane send-keys -X halfpage-down
# To copy, left click and drag to highlight text in yellow,
# once you release left click yellow text will disappear and will automatically be available in clibboard
# # Use vim keybindings in copy mode
setw -g mode-keys vi
# Update default binding of `Enter` to also use copy-pipe
unbind -T copy-mode-vi Enter
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xclip -selection c"
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -in -selection clipboard"
set -g visual-bell on
# https://stackoverflow.com/questions/32374907/tmux-mouse-copy-mode-jumps-to-bottom
unbind -T copy-mode-vi MouseDragEnd1Pane
I have following configuration in my tmux config file:
unbind C-b
set -g prefix C-s
bind-key - split-window -v
bind-key \ split-window -h
When I am in tmux, if I try
Ctrl+s : split-window -v
it works. If I try
Ctrl+s -
it does not work. It says No Buffer, and tmux does not do anything.
Any help on how can I debug this behaviour?
The - key is already bound to the delete-buffer command. You can check this by executing tmux list-keys. You must unbind it and then apply your binding:
unbind -
bind-key - split-window -v
I would like to remove a pane from being selected using ctrl+b arrow-keys. This is because I have a pane displaying the time using tmux clock-mode -t 2 and I do not ever want to switch into that pane.
This solution is similar to a problem I answered on sister site unix.stackexchange, and is not perfect.
tmux has a flag for each pane saying whether it is in a mode. For example, display -p #{pane_in_mode} for a pane in clock-mode prints 1.
Unfortunately, you cannot distinguish between, say, copy-mode and clock-mode. However, if you are unlikely to have many panes in a mode at a time, you can write a small shell script to intercept the appropriate bindings, and test if the resulting movement ended up in a pane in a mode. If so, the script repeats the movement, probably to the next window.
Create the following file mytmux in your PATH and make it executable (chmod +x mytmux):
#!/bin/bash
# https://stackoverflow.com/a/51232832/5008284
noclock(){
tmux "$#"
inmode=$(tmux display -p '#{pane_in_mode}')
[ "$inmode" = 1 ] && tmux "$#"
exit 0
}
case $1 in
-noclock)shift
: ${1?select-pane cmd and args}
noclock "$#" ;;
esac
then setup the following bindings in your ~/.tmux.conf:
bind-key -T prefix o run-shell 'mytmux -noclock select-pane -t :.+'
bind-key -T prefix l run-shell 'mytmux -noclock select-pane -l'
bind-key -r -T prefix Up run-shell 'mytmux -noclock select-pane -U'
bind-key -r -T prefix Down run-shell 'mytmux -noclock select-pane -D'
bind-key -r -T prefix Left run-shell 'mytmux -noclock select-pane -L'
bind-key -r -T prefix Right run-shell 'mytmux -noclock select-pane -R'
You will need to extend this if you want to handle multiple sessions, for example. I put select-pane -l in the bindings, but this is not useful, as if it repeats it will just go back to where you started from.
I switch panes often and when I press ctrl-a-right I move the the right. Then if I start typing "vim", the 'v' causes a ctrl-a-v (split vertically) to be issued, but I don't want this. How do I make tmux realize this?
In your .tmux.conf, add
bind Up select-pane -U
bind Down select-pane -D
bind Left select-pane -L
bind Right select-pane -R
or if you're using vim directions,
bind k select-pane -U
bind j select-pane -D
bind h select-pane -L
bind l select-pane -R
as detailed in this post: https://superuser.com/a/1273727
My solution was to remove -r in .tmux.conf on the split-window options. Removing -r causes repeats to be disabled.
from
bind -r v split-window -h -c "#{pane_current_path}"
to
bind v split-window -h -c "#{pane_current_path}"
Here is my .tmux.conf
set-option -g prefix C-\
bind-key C-p select-pane -U
bind-key C-n select-pane -D
bind-key C-b select-pane -L
bind-key C-f select-pane -R
What I want is to bind C-\ C-b to switch to the left pane, C-\ C-f to switch to the right pane and etc.
But I got the message .tmux.conf:2: usage: set-option [-agosquw] [-t target-session|target-window] option [value] when I started tmux.
Any idea how to do it?
It has to do with your choice of prefix being C-\. The '\' character is used to indicate that the next line is a continuation of the set-option command. Add a gap after C-\ or quote C-\ as explained here: https://superuser.com/questions/417236/tmux-with-non-alphanumeric-prefix
You can use the following:
set-option -g prefix 'C-\'
bind-key C-p select-pane -U
bind-key C-n select-pane -D
bind-key C-b select-pane -L
bind-key C-f select-pane -R