Date Tags TMUX / vim

why tmux

i believe anyone who is new to tmux can be frustrated by its "ugly" user interface and weird key bindings (especially those who don't use vim very often). "why the hell is this ugly terminal tool called a productivity tool?", well, just like vim/zsh, with a little bit (probably very much) customization, it can be a beautiful and powerful tool that you will fall in love with:

/img/tmux.png

for me, i was just seeking a utility that can help me split the terminal, coz i often need to open several terminal windows and vim windows at once, for malware analysis, or programming, or any workflow that has a lot of stuff to deal with at once. you might think you can just keep opening new windows, but hell no, i dont want to rearrange every window i open and move between mouse and keyboard from time to time. perhaps tiling wm like i3wm can solve this issue for me, but i really prefer a full-feature DE like the one i am using right now (yea, kde). tilix and terminator can be good for some people too, but i just dont want to use terminals other than konsole.

so thats it, i have to use tmux. like it or not, using tmux brings you cross-machine experience, even on remote servers without Xorg, tmux works just the same, makes you feel at home.

.tmux

yes, thats exactly what its called, actually it can be called "oh-my-tmux" too. unlike oh-my-zsh, .tmux will probably not work at first, it might need some post-installation work, to make powerline symbols show up, as well as colors.

dont worry, ive adapted it to get my tmux working, and i will show you how.

how to install

$ cd
$ git clone https://github.com/gpakosz/.tmux.git
$ ln -s -f .tmux/.tmux.conf
$ cp .tmux/.tmux.conf.local .

just follow its doc.

colors?

you might see horrible color scheme after installation. to fix this, you need to set a correct $TERM, mine is xterm-256color, make sure you change that in ~/.tmux/.tmux.conf too:

# -- general -------------------------------------------------------------------

set -g default-terminal "xterm-256color" # colors!

also in ~/.tmux.conf.local:

set -ga terminal-overrides ",xterm-256color:Tc" # set terminal type
set -g mouse on # enable mouse

and enable 24bit colors:

# -- display -------------------------------------------------------------------

# RGB 24-bit colour support (tmux >= 2.2), possible values are:
#  - true
#  - false (default)
tmux_conf_theme_24b_colour=true

powerline symbols?

make sure you have installed powerline fonts and/or you are using a powerline-patched font, just like what .tmux's doc says

the import thing is, use the right symbol:

powerline

prefix key

change the prefix key if you want (YES HELL YOU DO! i bet you will not use C-b, too damn silly it is! imagine how you can reach B when pressing Ctrl):

# replace C-b by C-a instead of using both prefixes
set -gu prefix2
unbind C-a
unbind C-b
set -g prefix C-a
bind C-a send-prefix
# or change C-a to any other key bindings you like

clipboard

yes, .tmux has covered that too:

# -- clipboard -----------------------------------------------------------------

# in copy mode, copying selection also copies to the OS clipboard
#   - true
#   - false (default)
# on macOS, this requires installing reattach-to-user-namespace, see README.md
# on Linux, this requires xsel or xclip
tmux_conf_copy_to_os_clipboard=true

i have to admit, using tmux is not as easy as i3wm or terminator, even with .tmux key bindings.

but the key bindings can be easy to remember, and less likely to conflict with other key bindings that already exist in your system.

read .tmux's doc, you will find its easier than you think. the frequently used key bindings are easy to get used to.

use it everywhere!

why not? one piece of config file, same experience everywhere.

why not use tmux as your default shell?

yes you can!

konsole config

konsole

or... launch vim in tmux every time

add this to your .zshrc or .bashrc:

if [ -z ${TMUX} ]; then
    alias vim='tmux new-session -s vim vim'
fi

Comments

comments powered by Disqus