# colors
set -g default-terminal "screen-256color"

# C-b is not acceptable -- Vim uses it
set-option -g prefix C-a
bind-key C-a last-window

# Start numbering at 1
set -g base-index 1

# start with pane 1
set -g pane-base-index 1

# Allows for faster key repetition
set -s escape-time 0

# Rather than constraining window size to the maximum size of any client
# connected to the *session*, constrain window size to the maximum size of any
# client connected to *that window*. Much more reasonable.
setw -g aggressive-resize on

# Allows us to use C-a a <command> to send commands to a TMUX session inside
# another TMUX session
bind-key a send-prefix

# Status Bar
set-option -g status on                # turn the status bar on
set -g status-interval 5               # 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 off
set-option -g visual-bell off
set-option -g visual-silence off
set-option -g bell-action none
set -g visual-activity on


# Make mouse useful
set -gq mouse on
set -gq mouse-utf8 on
# set -gq mouse on
set -gq mouse-resize-pane on
set -gq mouse-select-window on

# Allow mouse to select which pane to use
set -gq mouse-select-pane on

# Scroll History
# set -g history-limit 4096
# i have 32 gigs of ram haha
set -g history-limit 10000

# unicode
setw -gq utf8 on
set -gq status-utf8 on

# 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 %b %Y #[fg=green]:: %R" # :: #(date -u | awk '{print $4}')::"


# show host name and IP address on left side of status bar
set -g status-left-length 70
set -g status-left "#[fg=green]: #h : #[fg=blue]#(curl -4 icanhazip.com) #[fg=yellow]#(ifconfig en0 | grep 'inet ' | awk '{print \"en0 \" $2}') #(ifconfig en1 | grep 'inet ' | awk '{print \"en1 \" $2}') #[fg=red]#(ifconfig tun0 | grep 'inet ' | awk '{print \"vpn \" $2}') "


unbind [
bind Escape copy-mode
unbind p
bind p paste-buffer
# in copy mode can use visual style copy
# tmux version < 2.3
# bind-key -tq vi-copy 'v' begin-selection
# bind-key -tq vi-copy 'y' copy-selection

# new way for v2.3 >
# bind-key -T edit-mode-vi Up send-keys -X history-up
# bind-key -T edit-mode-vi Down send-keys -X history-down
unbind-key -T copy-mode-vi Space     ;   bind-key -T copy-mode-vi v send-keys -X begin-selection
#unbind-key -T copy-mode-vi Enter     ;   bind-key -T copy-mode-vi y send-keys -X copy-selection
unbind-key -T copy-mode-vi Enter     ;   bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xsel -i --clipboard"
# unbind-key -T copy-mode-vi Enter     ;   bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
# unbind-key -T copy-mode-vi C-v       ;   bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle
# unbind-key -T copy-mode-vi [         ;   bind-key -T copy-mode-vi [ send-keys -X begin-selection
# unbind-key -T copy-mode-vi ]         ;   bind-key -T copy-mode-vi ] send-keys -X copy-selection

# auto copy tmux buffer to clipboard
# bind-key -t vi-copy 'y' copy-pipe copy-selection 'xclip -in -selection clipboard'

# use vi mode
setw -gq mode-keys vi
set -gq status-keys vi

# splitting
# #pane{pane_current_path} makes directory of current path default in the new
# split or pane
unbind %
bind h split-window -h -c "#{pane_current_path}" # Split panes horizontal
unbind '"'
bind v split-window -v -c "#{pane_current_path}" # Split panes veritcally
unbind c
bind c new-window -c "#{pane_current_path}" # Create new window

# toggle status bar visibility
bind t set status

set -s copy-command 'xsel -s'

# Other examples
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin 'git@github.com/user/plugin'
# set -g @plugin 'git@bitbucket.com/user/plugin'

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-open'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'seebi/tmux-colors-solarized'
set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @yank_selection_mouse 'clipboard'
set -g @colors-solarized 'dark'

# source ~/.tmuxline.conf
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
