# History
set -g history-limit 10000

# Vi support
	set-window-option -g mode-keys vi
	set -g status-keys vi
	set -g escape-time 0

# Mouse support
	set -g mouse on

# Rebinds
	# Meta
		unbind-key C-b
		set -g prefix C-a
	# Panes
		unbind-key -n M-v
		unbind-key -n M-s
		bind-key -n M-v split-window -h
		bind-key -n M-s split-window
		unbind-key -n M-h
		unbind-key -n M-j
		unbind-key -n M-k
		unbind-key -n M-l
		bind-key -n M-h select-pane -L
		bind-key -n M-j select-pane -D
		bind-key -n M-k select-pane -U
		bind-key -n M-l select-pane -R
	# Windows
		unbind-key -n M-T
		unbind-key -n M-t
		unbind-key -n M-H
		unbind-key -n M-J
		unbind-key -n M-L
		bind-key -n M-T new-window
		bind-key -n M-t new-window -c "#{pane_current_path}"
		bind-key -n M-H previous-window
		bind-key -n M-J choose-tree
		bind-key -n M-L next-window
		unbind-key -n M-Q
		bind-key -n M-Q killw
	# Copy mode
		unbind-key -n C-Space
		bind-key -n C-Space copy-mode
		unbind-key -T copy-mode-vi v
		bind-key -T copy-mode-vi v send-keys -X begin-selection
		unbind-key -T copy-mode-vi y
		bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel \; run -b "tmux save-buffer - | \xclip -i -sel clipboard"
		unbind-key p
		bind-key p paste-buffer -p
		# Open in browser	// requires $BROWSER env-update
		bind-key -T copy-mode-vi   O send-keys -X copy-pipe-and-cancel "xargs ${BROWSER}"
		bind-key -T copy-mode      O send-keys -X copy-pipe-and-cancel "xargs ${BROWSER}"

# Environment
	set -ga update-environment ' FAVCHAR'
	set -ga update-environment ' LINES'
	set -ga update-environment ' COLUMNS'
	set -ga update-environment ' BROWSER'

# Looks
	set -g status on
	set -g status-position top
	set -g status-interval 1
	set -g renumber-windows on
	set -g base-index 1
	#
	set -g status-style "bg=color25 fg=white bold"
	set -g pane-border-style "fg=white"
	set -g pane-active-border-style "fg=white"
	set -g message-style "fg=green"
	#
	#set -g window-style "fg=colour240"
	#set -g window-active-style "fg=white bg=default"
	#
	set -g status-left-length 60
	#set -g status-left "#[fg=color24]|#[fg=default] {#{user}#{?#{FAVCHAR},#{FAVCHAR},@}#h} #[fg=color24]|#[fg=default] <#{?#{LINES},#{LINES},?}x#{?#{COLUMNS},#{COLUMNS},?}> #[fg=color24]|#[fg=default] (#I/#{session_windows}) "
	set -g status-left "#[fg=color16]|#[fg=default] {#{user}#{?#{FAVCHAR},#{FAVCHAR},@}#h} #[fg=color16]|#[fg=default] (#I/#{session_windows}) #[fg=color16]|#[fg=default] "
	set -g status-right-length 95
	set -g status-right "#[fg=color16]|#[fg=default] \"#{pane_title}\" #[fg=color16]|#[fg=default]"
	#
	set -g window-status-format "[ #{=/9/…:window_name} ]"
	set -g window-status-current-format "[ #{=/9/…:window_name}*]"
	set -g window-status-current-style "bg=white fg=color24"

# --- PLUGINS ---
# tmux-open (https://github.com/tmux-plugins/tmux-open)
bind-key -T copy-mode-vi   o send-keys -X copy-pipe-and-cancel \; run -b "sed 's/##/####/g' | xargs -I {} echo tmux run-shell -b 'cd #{pane_current_path}; xdg-open \"{}\" > /dev/null'"
bind-key -T copy-mode      o send-keys -X copy-pipe-and-cancel \; run -b "sed 's/##/####/g' | xargs -I {} echo tmux run-shell -b 'cd #{pane_current_path}; xdg-open \"{}\" > /dev/null'"
#bind-key -T copy-mode-vi C-o send-keys -X copy-pipe-and-cancel \; run -b "sed 's/##/####/g' | xargs -I {} echo tmux run-shell -b 'vim -- \"{}\"'"
#bind-key -T copy-mode    C-o send-keys -X copy-pipe-and-cancel \; run -b "sed 's/##/####/g' | xargs -I {} echo tmux run-shell -b 'vim -- \"{}\"'"
