# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix

# split panes using | and -
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %

# reload config file (change file location to your the tmux.conf you want to use)
bind r source-file ~/.tmux.conf

# switch panes using Alt-arrow without prefix
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D

# Enable mouse mode (tmux 2.1 and above)
set -g mouse on

# don't rename windows automatically
set-option -g allow-rename off

set -g default-terminal "xterm-256color"

# Use vim keybindings in copy-mode
set-window-option -g mode-keys vi

########### Copy and paste in tmux. ################################################

# In copy-mode use "v" for selection in visual mode.
# In copy-mode Use "space" for start selection
# In copy-mode use "arrow keys" for navigation, selecting text.
# In copy-mode use "Enter" for end selection. And Finally,
# In normal mode use "P" for pasting text.
# For copy and paste using mouse selection.
  # Hold Shift (On Ubuntu) and Alt (On Mac)
  # while copying the text. Paste can be done normally.

bind j copy-mode  # This binding is due to our vimrc.
bind P paste-buffer

bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-selection
bind-key -T copy-mode-vi r send-keys -X rectangle-toggle
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -sel clip -i'

# bind -T copy-mode-vi 'v' send -X rectangle-toggle
# bind -T copy-mode-vi Enter send -X copy-pipe-and-cancel "xclip -i -f -selection primary | xclip -i -selection clipboard"

####################################################################################
source /home/nikhil/.local/lib/python3.7/site-packages/powerline/bindings/tmux/powerline.conf
set-option -g default-terminal "screen-256color"
# Copying and pasting with tmux 2.4+
# https://tmuxcheatsheet.com/
# Everything you need to know about tmux copy and paste rushiagr
# :list-keys -T copy-mode-vi
# bind-key -T copy-mode-vi WheelUpPane send -X scroll-up
