tmux - add hostname
[dotfiles.git] / tmux.conf
1 ###############################################
2
3 # dependencies:
4 #       brew install reattach-to-user-namespace # for macvim
5
6
7 #set -g prefix ^O
8 #unbind ^b
9 #bind o send-prefix
10 unbind-key C-b
11 set -g prefix 'C-\'
12 bind-key 'C-\' send-prefix
13
14 set -g  status-fg  white
15 #set -g         status-bg  blue
16 #set -g         status-bg black 
17 set-window-option -g  window-status-current-bg red
18 #set-option -g  status-right "#[fg=green]#T  #[fg=yellow,bold]#(date '+%Y-%m-%d %I:%M%P %a') "
19 #set-option -g  status-right "#[fg=green]#(whoami)  #[fg=yellow,bold]#(date '+%Y-%m-%d') #[fg=red,bold]#(date '+%I:%M') #[fg=yellow,bold]#(date '+%p %a') "
20 set-option -g status-right-length 60
21 set-option -g  status-right "#[fg=red]#(hostname) #[fg=red]#(echo $SSH_CONNECTION | awk '{print $3}')  #[fg=yellow]#(date '+%Y-%m-%d') #[fg=red]#(date '+%I:%M') #[fg=yellow]#(date '+%p %a') "
22 if-shell 'test "$(uname)" = "Darwin"' 'set -g   status-bg black' 
23 if-shell 'test "$(uname)" = "Linux"' 'set -g    status-bg blue' 
24
25 ## automatic change the window title 
26 #set-option -g  set-titles      on
27 #set-option -g  set-titles-string       '#T'
28 #set-option -g  set-titles-string       "#(date '+%I:%M %P %a')"
29 #set-window-option -g   automatic-rename        on
30 set-option -g allow-rename off
31
32
33 #http://unix.stackexchange.com/questions/12032/create-new-window-with-current-directory-in-tmux
34 bind-key -n  "M-t"      new-window #-c '#{pane_current_path}'
35 bind-key -n  "M-n"      next-window
36 bind-key -n  "M-p"      previous-window
37 bind-key -n  "M-Space"  last-window
38
39
40 bind-key -n  "M-`"      select-window -t:0
41 bind-key -n  "M-1"      select-window -t:1
42 bind-key -n  "M-2"      select-window -t:2
43 bind-key -n  "M-3"      select-window -t:3
44 bind-key -n  "M-4"      select-window -t:4
45 bind-key -n  "M-5"      select-window -t:5
46 bind-key -n  "M-6"      select-window -t:6
47 bind-key -n  "M-7"      select-window -t:7
48 bind-key -n  "M-8"      select-window -t:8
49 bind-key -n  "M-9"      select-window -t:9
50
51 #bind-key -n  "C-M-h"   split-window -h
52 #bind-key -n  "C-M-v"   split-window -v
53 bind-key -n  "M-v"              split-window -h -c '#{pane_current_path}'
54 bind-key -n  "M-s"              split-window -v -c '#{pane_current_path}'
55
56 ##bind-key   "o"                select-pane -l
57 ##bind-key   "j"                select-pane -D
58 ##bind-key   "k"                select-pane -U
59 ##bind-key   "h"                select-pane -R
60 ##bind-key   "l"                select-pane -L
61
62 bind-key   "C-h"                resize-pane -L 3
63 bind-key   "C-j"                resize-pane -D 3
64 bind-key   "C-k"                resize-pane -U 3
65 bind-key   "C-l"                resize-pane -R 3
66
67 bind-key -n     "M-j"   select-pane     -D
68 bind-key -n     "M-k"   select-pane     -U
69 bind-key -n     "M-l"   select-pane     -R
70 bind-key -n     "M-h"   select-pane     -L
71 #bind-key -n    "M-o"   select-pane     -l
72
73 set-option      -g      mode-keys vi
74
75 ##set-window-option     -g      utf8 on
76
77 bind-key -n "M-i" copy-mode 
78
79
80 # refer http://askubuntu.com/questions/350718/problem-regarding-tmux-copy-mode
81 # $ tmux list-keys -t vi-copy
82 bind-key -t vi-copy "v" begin-selection
83 bind-key -t vi-copy "Space" page-down
84 bind-key -t vi-copy "BSpace" page-up
85 bind-key -t vi-copy "y" copy-selection  
86 bind-key -t vi-copy "K" halfpage-up
87 bind-key -t vi-copy "J" halfpage-down
88 #http://unix.stackexchange.com/questions/15715/getting-tmux-to-copy-a-buffer-to-the-clipboard
89 bind -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
90 ### mouse enable
91 # Reload tmux config
92 #bind r source-file ~/.tmux.conf
93 bind r source-file ~/.tmux.conf \; display "Reloaded!"
94 #set-option     -g      mouse-select-window  on
95 #set-option     -g      mouse-select-pane       on
96 #set-option     -g      mouse-resize-pane       on
97 #set-option     -g      mouse-utf8      on
98
99 #set-window-option      -g      mode-mouse      on
100
101 #set -g default-terminal "screen-256color"
102
103 ## macvim starting from tmux does't have "+ register, cannot using command+v to paste
104 # https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard/blob/master/Usage.md
105 # http://stackoverflow.com/questions/16618992/cant-paste-into-macvim
106 # set-option -g default-command 'reattach-to-user-namespace -l "$SHELL"'
107 set-option -g default-command 'command -v reattach-to-user-namespace >/dev/null && exec reattach-to-user-namespace -l "$SHELL" || exec "$SHELL"'
108
109
110
111 #set-option -g pane-border-fg colour235 #base02
112 #    set-option -g pane-active-border-fg colour240 #base01
113 #set -g status-justify centre
114 #setw -g monitor-activity on
115 #    set -g visual-activity on
116
117
118 #       set-window-option -g window-status-fg brightblue #base0
119 #    set-window-option -g window-status-bg colour236 
120 #    set-window-option -g window-status-attr dim
121
122 #    set-window-option -g window-status-current-fg brightred #orange
123 #    set-window-option -g window-status-current-bg colour236 
124 #    set-window-option -g window-status-current-attr bright
125
126 set-option -g base-index 1
127 setw -g pane-base-index 1
128 set-option -sg escape-time 0
129
130 #http://www.tylercipriani.com/2013/09/12/important-lines-in-my-tmux.html
131 #bind-key -n "M-\\" resize-pane -Z #\; display-message "Zoom zoom zoom"
132 bind-key -n "M-o" resize-pane -Z #\; display-message "Zoom zoom zoom"
133
134 set -g renumber-windows on
135 set-option -g history-limit 10000