My .tmux.conf looks like this:
#remap default "prefix" from Ctrl-b to Ctrl-a
set -g prefix C-a
# mouse options for selecting pane
set -g mode-mouse on
set -g mouse resize-pane on
set -g mouse-select-pane on
set -g mouse-select-window on
# Use vim keybindings in copy mode
setw -g mode-keys vi
# Setup 'v' to begin selection as in Vim
bind-key -t vi-copy v begin-selection
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
# Update default binding of `Enter` to also use copy-pipe
unbind -t vi-copy Enter
bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"
I am sourcing it using `source ~/.tmux.conf' and it gives me error messages. I am just trying to setup an easy option for copy and paste. Why isn't it identifying the set -g option?
-bash: set: -g: invalid option
set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
-bash: set: -g: invalid option
set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
-bash: set: -g: invalid option
set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
-bash: set: -g: invalid option
set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
-bash: set: -g: invalid option
set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
-bash: setw: command not found
-bash: bind-key: command not found
-bash: bind-key: command not found
-bash: unbind: command not found
-bash: bind-key: command not found
The "source ~/tmux.conf" you were presumably told to execute is a tmux command, not a bash one. You're supposed to type it into the Prefix : prompt
You are not supposed to source it within your shell, but rather tell tmux to source it. Run the following in your terminal:
tmux source ~/.tmux.conf
Just tmux source ~/.tmux.conf from the command line also works.
Related
i'm trying to follow a guide in which it's explained how to get copy/paste working without shift.
but with the following config :
set -g mouse on
set -g #plugin 'tmux-plugins/tpm'
set -g #plugin 'tmux-plugins/tmux-yank'
set -g #yank_action 'copy-pipe-no-clear'
set -g #override_copy_command 'xsel -i --clipboard'
set -g #yank_selection_mouse 'primary'
set -g #yank_selection 'primary'
bind -T copy-mode C-c send -X copy-pipe-no-clear "xsel -i --clipboard"
bind -T copy-mode-vi C-c send -X copy-pipe-no-clear "xsel -i --clipboard"
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
I'm expecting to select something with the mouse, press y or Control-c, then go to any other app, press Control-v and have my selection pasted, but nothing happens.
when I list the keys I can see my bind:
bind-key -T copy-mode C-c send-keys -X copy-pipe-no-clear "xsel -i --clipboard"
and xsel works fine on its own :
$ echo hello | xsel -i --clipboard # C-V contains 'hello' as expected
What am i doing wrong?
I am using tmux and zsh.
When I am outside tmux, zsh is customized with some Manjaro settings, as per the .zshrc
# Use powerline
USE_POWERLINE="true"
# Source manjaro-zsh-configuration
if [[ -e /usr/share/zsh/manjaro-zsh-config ]]; then
source /usr/share/zsh/manjaro-zsh-config
fi
# Use manjaro zsh prompt
if [[ -e /usr/share/zsh/manjaro-zsh-prompt ]]; then
source /usr/share/zsh/manjaro-zsh-prompt
fi
# Use ssh-agent
if [[ -e /home/marcosh/ssh-agent.zsh ]]; then
source /home/marcosh/ssh-agent.zsh
fi
source /usr/share/nvm/init-nvm.sh
When I am inside tmux though, the customizations are missing, eventhough it is using zsh. This is my .tmux.conf
set-option -g history-limit 50000
# sane scrolling
set-option -g mouse on
set -ga terminal-overrides ',xterm*:smcup#:rmcup#'
# new pane on same folder
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
# use zsh instead of bash
set -g default-command /usr/bin/zsh
What should I do to get the same zsh configuration both when inside and outside tmux?
The problem is tmux is not rendering the UTF-8 characters from the manjaro config properly.
To solve this use:
tmux -u
From the tmux manpage:
-u Write UTF-8 output to the terminal even if the first
environment variable of LC_ALL, LC_CTYPE, or LANG that
is set does not contain "UTF-8" or "UTF8". This is
equivalent to -T UTF-8.
I have the following in my ~/.tmux.conf file
# improved (vi) copy paste
#
# vi mode in tmux
setw -g mode-keys vi
bind-key -t vi-copy y copy-selection
# select entire line
bind-key -t vi-copy v select line
Up till today this has always worked perfectly, problem is I've updated to the latest version :(.
tmux -V shows me that I'm currently at version 2.4
The vi-copy bindings are not working anymore. It seems that vi-copy mode is broken. If I execute the following:
CTRL+<leader> :list-keys -t vi-copy
The output is:
Unknown key-table vi-copy
According to this, it is a known issue
And you now have to do the following (extracted comment from the above link):
Basically you now need to bind your key in the copy-mode-vi table now,
look at how the default key bindings are done with "tmux lsk". For
your example: bind -Tcopy-mode-vi v send -X begin-selection
I'm sharing my tmux configuration across varous PC's, which are running different tmux versions, I hope somebody can explain how a cross compatible tmux configuration can be created, in which I can have the same keybindings and vi mode behaviour.
I have the following snippet in my tmux.conf:
if-shell "tmux -V | awk '{exit($2<2.4?0:1)}'" \
"bind-key -t vi-copy 'v' begin-selection; bind-key -t vi-copy 'y' copy-selection" \
"bind-key -T copy-mode-vi 'v' send -X begin-selection; bind-key -T copy-mode-vi 'y' send -X copy-selection"
Not the prettiest code I wrote but it seems to work.
tmux has a command mode that can be accessed via C-b : and I'm wondering if there is a way to alias commands in my .tmux.conf file like split-window to something I use more often like vsp in vim.
I know I can bind keyboard shortcuts with bind but can I alias commands as well?
tmux 2.4 adds the command-alias array option which does this, so for example you can do
:set -s command-alias[10] vsp='split-window -h'
And then you can use :vsp in the command-prompt just like you'd expect.
This doesn't appear to be possible as of tmux 2.0.
One thing you can do, however, is send commands to the enclosing tmux session from the shell. This means that you can, for example, create a bash alias that can split windows:
alias vsp="tmux split-window -h"
You can then run vsp from your bash prompt to split the tmux window vertically. Depending on your specific use case, this might help.
It's also worth noting that, if minimising typing is the goal, tmux commands can be shortened to their shortest unambiguous prefix: sp does the same thing as split-window.
There's a mod allowing not only alias but also create new commands in tmux: http://ershov.github.io/tmux/
For example:
proc vsp {args} { split-window -h {*}$args }
No external shell involved, no new processes spawned.
You can use bind. Here is an example alias for turning mouse-mode on and off:
bind m \
set -g mode-mouse on \;\
set -g mouse-resize-pane on \;\
set -g mouse-select-pane on \;\
set -g mouse-select-window on \;\
display 'Mouse mode ON'
bind M \
set -g mode-mouse off \;\
set -g mouse-resize-pane off \;\
set -g mouse-select-pane off \;\
set -g mouse-select-window off \;\
display 'Mouse mode OFF'
Now you can easily use Ctrl+B m to turn it on, and Ctrl+B M to turn it off (assuming Ctrl+B is your prefix)
Yep. Using bind-key in you tmux.conf. For example to split tmux windows use:
bind-key v split-window -v #C-b v to split vertically
bind-key h split-window -h #C-b h horizontal
If you don't want to use prefix (C-b) just add -n param:
bind-key -n C-right next # C - → to move to next window.
I started using tmux recently and things are good except for the fact that tmux prints out my last run command before output, e.g.:
~ $ pwd
pwd/Users/me
You can see that it put "pwd" before the directory there, which is annoying.
My shell(zsh) doesn't do this when I run commands outside of tmux.
show-environment -g doesn't reveal any weird options being passed to zsh or anything: SHELL=/bin/zsh
I read through the manpage and Googled around but I can't find anything.
Thanks for any help!
Figured it out -- needed to change my ~/.tmux.conf to have a different TERM(xterm instead of screen-256color):
# act like vim
setw -g mode-keys vi
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind-key -r C-h select-window -t :-
bind-key -r C-l select-window -t :+
# act like GNU screen
unbind C-b
set -g prefix C-a
# look good
#set -g default-terminal "screen-256color"
set -g default-terminal "xterm"
set -g status "off"