Created
January 6, 2017 12:40
-
-
Save vzarytovskii/1b159705bdd63eba907129995923e4f5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cat << ►_◄ > /dev/null | |
# -- general ------------------------------------------------------------------- | |
#set-option -g default-shell /usr/local/bin/fish | |
set -g default-terminal "screen-256color" # colors! | |
setw -g xterm-keys on | |
set -s escape-time 0 # fastest command sequences | |
set -sg repeat-time 600 # increase repeat timeout | |
set -s quiet on # disable various messages | |
set -g prefix2 C-a # GNU-Screen compatible prefix | |
bind C-a send-prefix -2 | |
set -g status-utf8 on # expect UTF-8 | |
setw -g utf8 on | |
set -g history-limit 50000 # boost history | |
bind e new-window -n '~/.tmux.conf' '${EDITOR:-vim} ~/.tmux.conf && tmux source ~/.tmux.conf && tmux display "~/.tmux.conf sourced"' | |
bind-key u capture-pane \; save-buffer /tmp/tmux-buffer \; new-window -n "urlview" '$SHELL -c "urlview < /tmp/tmux-buffer"' | |
bind r source-file ~/.tmux.conf \; display '~/.tmux.conf sourced' | |
set -g default-command "initializing() { $(command -v reattach-to-user-namespace) $SHELL -l; }; initializing" | |
set -g mode-mouse off | |
setw -g mouse-select-window on | |
setw -g mouse-select-pane on | |
setw -g mode-keys vi | |
setw -g automatic-rename on # rename window to reflect current program | |
if '[ $(echo "$(tmux -V | cut -d' ' -f 2) > 1.6" | bc) -eq 1 ]' 'set -g renumber-windows on' | |
set -g set-titles on # set terminal title | |
set -g set-titles-string '#h ❐ #S ● #I #W' | |
set -g display-panes-time 800 # slightly longer pane indicators display time | |
set -g display-time 1000 # slightly longer status messages display time | |
set -g status-interval 1 # redraw status line every 10 seconds | |
set -g status-justify centre | |
setw -g clock-mode-style 24 | |
bind -n C-l send-keys C-l \; run 'tmux clear-history' | |
set -g monitor-activity on | |
set -g visual-activity off | |
tmux_conf_theme=powerline_patched_font | |
bind C-c new-session | |
bind C-f command-prompt -p find-session 'switch-client -t %%' | |
bind | split-window -h -c "#{pane_current_path}" | |
bind _ split-window -v -c "#{pane_current_path}" | |
bind x killp | |
# pane navigation | |
bind -r h select-pane -L # move left | |
bind -r j select-pane -D # move down | |
bind -r k select-pane -U # move up | |
bind -r l select-pane -R # move right | |
bind > swap-pane -D # swap current pane with the next one | |
bind < swap-pane -U # swap current pane with the previous one | |
# maximize current pane | |
bind + run 'cut -c3- ~/.tmux.conf | sh -s maximize_pane' | |
# pane resizing | |
bind -r H resize-pane -L 2 | |
bind -r J resize-pane -D 2 | |
bind -r K resize-pane -U 2 | |
bind -r L resize-pane -R 2 | |
# window navigation | |
bind -r C-h previous-window # select previous window | |
bind -r C-l next-window # select next window | |
bind Space last-window # move to last active window | |
# toggle mouse | |
bind m run "cut -c3- ~/.tmux.conf | sh -s toggle_mouse" | |
# -- copy mode ----------------------------------------------------------------- | |
bind Enter copy-mode # enter copy mode | |
bind b list-buffers # list paster buffers | |
#bind p paste-buffer # paste from the top pate buffer | |
bind P choose-buffer # choose which buffer to paste from | |
# the following vi-copy bindings match my vim settings | |
# see https://github.com/gpakosz/.vim.git | |
bind -t vi-copy v begin-selection | |
bind -t vi-copy C-v rectangle-toggle | |
#bind -t vi-copy y copy-selection | |
#bind-key -t vi-copy y run-shell 'tmux save-buffer - | reattach-to-user-namespace pbcopy' | |
#bind-key -t vi-copy p run-shell 'reattach-to-user-namespace pbpaste | tmux load-buffer - \; paste-buffer -d' | |
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy" | |
bind p paste-buffer | |
bind -t vi-copy Escape cancel | |
bind -t vi-copy H start-of-line | |
bind -t vi-copy L end-of-line | |
set -g base-index 1 # start windows numbering at 1 | |
setw -g pane-base-index 1 # make pane numbering consistent with windows | |
# copy to Mac OSX pasteboard | |
#if 'command -v reattach-to-user-namespace' 'bind y run "tmux save-buffer - | reattach-to-user-namespace pbcopy"' | |
# -- user defined -------------------------------------------------------------- | |
if '[ -f ~/.tmux.conf.local ]' 'source ~/.tmux.conf.local' | |
# -- 8< ------------------------------------------------------------------------ | |
run 'cut -c3- ~/.tmux.conf | sh -s apply_theme $tmux_conf_theme' | |
run 'for name in $(printenv | grep -Eo ^tmux_conf_[^=]+); do tmux setenv -gu $name; done;' | |
# ►_◄ | |
# # exit the script if any statement returns a non-true return value | |
# set -e | |
# | |
# apply_theme() { | |
# case "$1" in | |
# powerline_patched_font) | |
# left_separator='' | |
# left_separator_black='' | |
# right_separator='' | |
# right_separator_black='' | |
# session_symbol='' | |
# ;; | |
# powerline) | |
# left_separator='|' | |
# left_separator_black=' ' | |
# right_separator='|' | |
# right_separator_black=' ' | |
# ;; | |
# esac | |
# | |
# case "$1" in | |
# powerline*) | |
# | |
# # panes | |
# pane_border_fg=colour240 # light gray | |
# pane_active_border_fg=colour16 # light blue | |
# | |
# tmux set -g pane-border-style fg=$pane_border_fg \; set -g pane-active-border-style fg=$pane_active_border_fg | |
# #uncomment for fat borders | |
# #tmux set -ga pane-border-style bg=$pane_border_fg \; set -ga pane-active-border-style bg=$pane_active_border_fg | |
# | |
# display_panes_active_colour=colour16 # light blue | |
# display_panes_colour=colour16 # light blue | |
# tmux set -g display-panes-active-colour $display_panes_active_colour \; set -g display-panes-colour $display_panes_colour | |
# | |
# # messages | |
# message_fg=colour16 #black | |
# message_bg=colour240 #yellow | |
# message_attr=bold | |
# tmux set -g message-style fg=$message_fg,bg=$message_bg,$message_attr | |
# | |
# # windows mode | |
# mode_fg=colour16 #black | |
# mode_bg=colour240 #yellow | |
# mode_attr=bold | |
# tmux setw -g mode-style fg=$mode_fg,bg=$mode_bg,$mode_attr | |
# | |
# # status line | |
# status_fg=colour253 # white | |
# status_bg=colour232 # dark gray | |
# tmux set -g status-style fg=$status_fg,bg=$status_bg | |
# | |
# session_fg=colour16 # black | |
# session_bg=colour240 # yellow | |
# status_left="#[fg=$session_fg,bg=$session_bg,bold] #S #[fg=$session_bg,bg=$status_bg,nobold]$left_separator_black" | |
# tmux set -g status-left-length 32 \; set -g status-left "$status_left" | |
# | |
# window_status_fg=colour16 | |
# window_status_bg=colour241 | |
# window_status_format="#[fg=$window_status_current_bg,bg=$window_status_bg,bold] #I $left_separator #W #[fg=$window_status_current_bg,bg=$status_bg,nobold]" | |
# tmux setw -g window-status-style fg="$window_status_fg",bg="$window_status_bg" \; setw -g window-status-format "$window_status_format" | |
# | |
# window_status_current_fg=colour16 | |
# window_status_current_bg=colour248 | |
# window_status_current_format="#[fg=$window_status_bg,bg=$window_status_current_bg]#[fg=$window_status_current_fg,bg=$window_status_current_bg,bold] #I $left_separator #W #[fg=$window_status_current_bg,bg=$status_bg,nobold]" | |
# tmux setw -g window-status-current-format "$window_status_current_format" | |
# tmux set -g status-justify centre | |
# | |
# window_status_activity_fg=colour16 # font | |
# window_status_activity_bg=green # background | |
# window_status_activity_attr=blink | |
# tmux setw -g window-status-activity-style fg=$window_status_activity_fg,$window_status_activity_attr,bg=$window_status_activity_bg | |
# | |
# time_date_fg=colour245 # light gray | |
# time_date_bg=colour232 # dark gray | |
# whoami_fg=colour254 # white | |
# whoami_bg=colour160 # red | |
# host_fg=colour16 # black | |
# host_bg=colour254 # white | |
# status_right="#[fg=$whoami_bg,bg=$time_date_bg,nobold]$right_separator_black#[fg=$whoami_fg,bg=$whoami_bg,nobold] %R %d %b " | |
# tmux set -g status-right-length 64 \; set -g status-right "$status_right" | |
# | |
# # clock | |
# clock_mode_colour=colour16 # light blue | |
# tmux setw -g clock-mode-colour $clock_mode_colour | |
# ;; | |
# esac | |
# } | |
# | |
# circled_digit() { | |
# circled_digits='⓪①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮⑯⑰⑱⑲⑳' | |
# if [ $1 -lt 20 ] 2>/dev/null ; then | |
# echo ${circled_digits:$1:1} | |
# else | |
# echo $1 | |
# fi | |
# } | |
# | |
# maximize_pane() { | |
# tmux -V |grep -q '1.9a\?$' && tmux display "tmux 1.9 and 1.9a have a bug that prevent this feature from working" && return | |
# __current_pane=$(tmux display -p '#{pane_id}') | |
# | |
# __dead_panes=$(tmux list-panes -s -F '#{pane_dead} #{pane_id} #{pane_title}' | grep -o '^1 %.\+%.\+$' || true) | |
# __restore=$(echo "${__dead_panes}" | sed -n -E -e "s/^1 ${__current_pane} \[\+\](%[0-9]+)$/tmux swap-pane -s \1 -t ${__current_pane} \; kill-pane -t ${__current_pane}/p" -e "s/^1 (%[0-9]+) \[\+\]${__current_pane}$/tmux swap-pane -s \1 -t ${__current_pane} \; kill-pane -t \1/p" ) | |
# | |
# if [ x"${__restore}" = x ] ; then | |
# [ x"$(tmux list-panes | wc -l | sed 's/^ *//g')" = x1 ] && tmux display "Can't maximize with only one pane" && return | |
# __window=$(tmux new-window -P "exec maximized+ 2> /dev/null | tmux setw remain-on-exit on && printf '\033]2;%s\033\\' [+]${__current_pane}") | |
# __window=${__window%.*} | |
# | |
# __guard=100 | |
# while ( [ x"$(tmux list-panes -t ${__window} -F '#{session_name}:#{window_index} #{pane_dead}')" != x"${__window} "1 ] && [ x"${__guard}" != x0 ] ) ; do sleep 0.01 ; _guard=$((__guard - 1)) ; done | |
# if [ x"${__guard}" = 0 ] ; then | |
# exit 1 | |
# fi | |
# | |
# __new_pane=$(tmux display -p '#{pane_id}') | |
# tmux setw remain-on-exit off \; swap-pane -s "${__current_pane}" -t "${__new_pane}" | |
# else | |
# ${__restore} | |
# fi | |
# } | |
# | |
# toggle_mouse() { | |
# old=$(tmux show -g -w | grep mode-mouse | cut -d' ' -f2) | |
# new="" | |
# | |
# if [ "$old" = "on" ] ; then | |
# new="off" | |
# else | |
# new="on" | |
# fi | |
# | |
# tmux set -g mode-mouse $new \;\ | |
# set -g mouse-resize-pane $new \;\ | |
# set -g mouse-select-pane $new \;\ | |
# set -g mouse-select-window $new \;\ | |
# display "mouse: $new" | |
# } | |
# | |
# battery() { | |
# battery_symbol=$1 | |
# battery_symbol_count=$2 | |
# if [ $battery_symbol_count = auto ]; then | |
# columns=$(tmux display -p '#{client_width}' || echo 80) | |
# if [ $columns -ge 80 ]; then | |
# battery_symbol_count=10 | |
# else | |
# battery_symbol_count=5 | |
# fi | |
# fi | |
# battery_full_fg=colour160 | |
# battery_full_bg=colour16 | |
# battery_empty_fg=colour254 | |
# battery_empty_bg=colour16 | |
# | |
# battery_symbol_heart_full=♥ | |
# battery_symbol_heart_empty=♥ | |
# battery_symbol_block_full=◼ | |
# battery_symbol_block_empty=◻ | |
# eval battery_symbol_full='$battery_symbol_'"$battery_symbol"'_full' | |
# eval battery_symbol_empty='$battery_symbol_'"$battery_symbol"'_empty' | |
# | |
# uname_s=$(uname -s) | |
# if [ $uname_s = Darwin ]; then | |
# batt=$(pmset -g batt) | |
# percentage=$(echo $batt |egrep -o [0-9]+%) || return | |
# charge="${percentage%%%} / 100" | |
# elif [ $uname_s = Linux ]; then | |
# batpath=/sys/class/power_supply/BAT0 | |
# if [ ! -d $batpath ]; then | |
# batpath=/sys/class/power_supply/BAT1 | |
# fi | |
# batfull=$batpath/energy_full | |
# batnow=$batpath/energy_now | |
# if [ ! -r $batfull -o ! -r $batnow ]; then | |
# return | |
# fi | |
# charge="$(cat $batnow) / $(cat $batfull)" || return | |
# fi | |
# | |
# full=$(printf %.0f $(echo "$charge * $battery_symbol_count" | bc -l)) | |
# [ $full -gt 0 ] && \ | |
# printf '#[fg=%s,bg=%s]' $battery_full_fg $battery_full_bg && \ | |
# printf "%0.s$battery_symbol_full" $(seq 1 $full) | |
# empty=$(($battery_symbol_count - $full)) | |
# [ $empty -gt 0 ] && \ | |
# printf '#[fg=%s,bg=%s]' $battery_empty_fg $battery_empty_bg && \ | |
# printf "%0.s$battery_symbol_empty" $(seq 1 $empty) | |
# } | |
# | |
# $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment