## Mouse options 
set -g mouse on
#bind -T root WheelUpPane   if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; copy-mode -e; send-keys -M"
#bind -T root WheelDownPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; send-keys -M"
   
## Start counting windows from 1
set -g base-index 1


setw -g mode-keys vi

# Copy/paste. Selecting any text with mouse automatically sopies it to the clipboard
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xsel -i -p -b"
bind-key p run "xsel -o | tmux load-buffer - ; tmux paste-buffer"
bind -n C-S-v run "xsel -o | tmux load-buffer - ; tmux paste-buffer"
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xsel -i -p && xsel -o -p | xsel -i -b"
bind-key -T copy-mode-vi C-c send-keys -X copy-pipe-and-cancel "xsel -i -p && xsel -o -p | xsel -i -b"
bind-key p run "xsel -o | tmux load-buffer - ; tmux paste-buffer"
#bind -n C-S-c "copy-pipe "xsel -i -p -b""
#bind-key C-S-c "copy-pipe "xsel -i -p -b""
## titles
set-window-option -g automatic-rename on
set-option -g set-titles on

## Toggle copymode
bind Escape copy-mode

##open and close splits
bind -n M-h split-window -h
bind -n M-v split-window -v
bind -n M-x killp
bind -n M-z resize-pane -Z
unbind '"'
unbind %


# Use Ctrl-arrows to navigate text
set-window-option -g xterm-keys on

# Use Alt-arrow keys without prefix key to switch panes
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

# Use Alt-Shift-arrow keys without prefix key to switch panes (for better micro compatibility)
# bind -n M-S-Left select-pane -L
# bind -n M-S-Right select-pane -R
# bind -n M-S-Up select-pane -U
# bind -n M-S-Down select-pane -D

# Shift arrow to switch windows
bind -n M-T new-window
bind -n S-PageDown prev
bind -n S-PageUp next
bind-key -n M-j detach

# No delay for escape key press
set -sg escape-time 0

# Reload tmux config
bind r source-file ~/.tmux.conf

#unbind C-b
#set -g prefix C-a
set -g prefix M-a

set -g pane-active-border-style fg=cyan 

setw -g aggressive-resize on
# ----------------------
    # Status Bar
    # -----------------------
    set-option -g status on                # turn the status bar on
    set -g status-interval 15               # set update frequencey (default 15 seconds)
    set -g status-justify centre           # center window list for clarity
    set-option -g status-position top    # position the status bar at top of screen

    # visual notification of activity in other windows
    setw -g monitor-activity on
    set -g visual-activity on

    # set color for status bar
    set-option -g status-bg colour00 #base02
    set-option -g status-fg cyan

	set -g  window-status-style dim
    set -g  window-status-current-style bright
 	set -g  window-status-separator ' | '

    # show host name
#    set -g status-left-length 70
#    set -g status-left "#[fg=green]: #h :"
# Don't show anything on the left side of the bar
    set -g status-left ""
    # show session name, window & pane number, date and time on right side of
    # status bar
#    set -g status-right-length 60
#    set -g status-right "#[fg=blue]#S #I:#P #[fg=yellow]:: %d/%m/%Y #[fg=green]:: %H:%M"
# Don't show anything on the right side of the bar
set -g status-right ""
#set -g default-command "/usr/bin/zsh"
#set -g default-shell "/usr/bin/fish"
set -g default-terminal screen-256color
set -as terminal-overrides ',st*:kind@:kri@'
# Better mouse support

set -g @prevent-scroll-for-fullscreen-alternate-buffer 'on'
set -g @scroll-speed-num-lines-per-scroll '3'
run-shell /usr/share/tmux/tmux-better-mouse-mode/scroll_copy_mode.tmux
