Skip to content

Commit 04f8156

Browse files
committed
Initial commit of tmux config and utils
0 parents  commit 04f8156

9 files changed

+505
-0
lines changed

autossh.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/python
2+
"""
3+
Usage: autossh.py <hostname> [<server> <sessionname>]
4+
5+
"""
6+
import os
7+
from docopt import docopt
8+
from sh import tmux
9+
10+
args = docopt(__doc__)
11+
hostname = args.get('<hostname>', 'autossh')
12+
port = None
13+
if ':' in hostname:
14+
hostname, port = hostname.split(':', 1)
15+
args['<sessionname>'] = args['<sessionname>'] or hostname.split('.', 1)[0]
16+
args['<server>'] = args['<server>'] or 'inner'
17+
print(args)
18+
19+
has_tmux = os.environ.get('TMUX')
20+
prev_window_name = None
21+
if has_tmux:
22+
prev_window_name = tmux("display-message", "-p", "x'#W")
23+
tmux("rename-window", hostname)
24+
25+
cmd = ["autossh", hostname, "-M", "0"]
26+
if port:
27+
cmd.extend(('-p', port))
28+
cmd.extend(("-t", "~/.bin/tmux.py {<server>} {<sessionname>}".format(**args)))
29+
print(cmd)
30+
os.execvpe("/usr/bin/autossh", cmd, os.environ)

aziz.conf

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
2+
## keybindings
3+
unbind C-b
4+
unbind C-a
5+
unbind %
6+
unbind ,
7+
unbind .
8+
unbind n
9+
unbind p
10+
unbind [
11+
unbind '"'
12+
unbind l
13+
unbind &
14+
unbind "'"
15+
16+
set-option -g prefix C-a # C-a for perfix just like screen
17+
18+
bind-key C-a last-window
19+
bind-key | split-window -h
20+
bind-key \ split-window -h
21+
bind-key - split-window -v
22+
bind-key x kill-pane
23+
bind-key X kill-window
24+
bind-key q confirm-before kill-session
25+
bind-key Q confirm-before kill-server
26+
bind-key , previous-window # <
27+
bind-key . next-window # >
28+
bind-key < swap-window -t :-
29+
bind-key > swap-window -t :+
30+
bind-key n command-prompt 'rename-window %%'
31+
bind-key N command-prompt 'rename-session %%'
32+
#bind-key Escape copy-mode
33+
#bind-key Up copy-mode
34+
bind-key [ copy-mode
35+
bind-key R refresh-client
36+
bind-key a send-key C-a
37+
bind-key C-j resize-pane -L 5
38+
bind-key C-l resize-pane -R 5
39+
bind-key C-k resize-pane -D 5
40+
bind-key C-i resize-pane -U 5
41+
42+
43+
## set status bar
44+
set-option -g status-utf8 on
45+
#set-option -g status-bg colour11
46+
#set-option -g status-fg colour8
47+
48+
#set-option -g status-left '⣿'
49+
#set-option -g status-right '⡇ #[bold]❐ #S:#I#[default] ⡇ #[bold]#(whoami) ● #H#[default] '
50+
#set-option -g status-right '⡇ ❐ #S ⡇ ❖ #(rvm tools identifier) ⡇ #(whoami) ● #H '
51+
#set-option -g status-left ' #[bold]❐ #S#[default] ⡇'
52+
#set-option -g status-right '#[bold]#(whoami) ● #H#[default] '
53+
54+
set-option -g status-right-length 60
55+
set-option -g status-left-length 60
56+
57+
## highlight active window
58+
#set-window-option -g window-status-current-bg cyan
59+
#set-window-option -g window-status-current-fg colour15
60+
set-window-option -g window-status-current-attr bold
61+
set-window-option -g window-status-current-format ' #I #W '
62+
63+
## set window notifications
64+
set-option -g visual-activity on
65+
set-option -g visual-content on
66+
set-window-option -g monitor-activity on
67+
set-window-option -g automatic-rename off
68+
69+
## tmux window titling for X
70+
set-option -g set-titles on
71+
set-option -g set-titles-string '[#I] #W'
72+
set-window-option -g automatic-rename on
73+
set-window-option -g window-status-format ' #I #W '
74+
set-window-option -g window-status-attr bold
75+
# starts windows at 1 not 0
76+
#set-option -g base-index 1
77+
78+
## enable mouse
79+
#set-option -g mouse-select-pane on
80+
set-window-option -g mode-keys vi
81+
#set-window-option -g mode-mouse on
82+
# set-window-option -g monitor-activity off
83+
# set-window-option -g monitor-content off
84+
# set-option -g status-keys vi
85+
# set-option -g history-limit 4096
86+
87+
## pane border and colors
88+
set-option -g pane-active-border-fg blue
89+
set-option -g pane-border-fg white

common.conf

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
set -g default-terminal "st-256color"
2+
set -sg escape-time 0
3+
#set default-command '/home/sjoseph/bin/zsh'
4+
#set-option -g status-right '#[fg=green]#(date +"%h %a %d %H:%M") #[fg=white]#(whoami)@#h'
5+
setw -g aggressive-resize off
6+
setw -g monitor-content off
7+
set -g visual-activity off
8+
#set-option -g mouse-select-pane on
9+
10+
#### COLOUR
11+
# default statusbar colors
12+
set-option -g status-bg colour235 #base02
13+
set-option -g status-fg colour136 #yellow
14+
set-option -g status-attr default
15+
16+
# default window title colors
17+
set-window-option -g window-status-fg colour244
18+
set-window-option -g window-status-bg default
19+
set-window-option -g window-status-attr dim
20+
21+
# active window title colors
22+
set-window-option -g window-status-current-fg colour7 #orange
23+
set-window-option -g window-status-current-bg colour27
24+
set-window-option -g window-status-current-attr bright
25+
26+
# pane border
27+
set-option -g pane-border-fg colour235 #base02
28+
set-option -g pane-active-border-fg colour240 #base01
29+
30+
# message text
31+
set-option -g message-bg colour235 #base02
32+
set-option -g message-fg colour166 #orange
33+
34+
# pane number display
35+
set-option -g display-panes-active-colour colour33 #blue
36+
set-option -g display-panes-colour colour166 #orange
37+
38+
# clock
39+
set-window-option -g clock-mode-colour colour64 #green
40+
41+
#window with alert
42+
set-window-option -g window-status-activity-fg colour234 #orange
43+
set-window-option -g window-status-activity-bg colour60
44+
set-window-option -g window-status-activity-attr dim
45+
46+
47+
#set -g status-left '#[fg=colour235,bg=colour252,bold] ⎈ #S #[fg=colour252,bg=colour238,nobold]⮀#[fg=colour245,bg=colour238,bold] #(whoami) #[fg=colour238,bg=colour234,nobold]⮀'
48+
#set -g status-left '#[fg=colour235,bg=colour252,bold] ⎈ #S #[fg=colour238,bg=colour234,nobold]'
49+
#set -g status-right '#(~/.tmux/status.sh)'
50+
#set -g status-right '$TMUX_STATUS_RIGHT'
51+
#set -g status-left '$TMUX_STATUS_LEFT'
52+
#set -g status-left '#(echo \$TMUX_STATUS_LEFT)'
53+
#set -g status-right '#(echo \$TMUX_STATUS_RIGHT)'
54+
set -g window-status-format "#[fg=white,bg=colour234] #I #W "
55+
#set -g window-status-current-format "#[fg=colour234,bg=colour39]⮀#[fg=colour25,bg=colour39,noreverse,bold] #I ⮁ #W #[fg=colour39,bg=colour234,nobold]⮀"
56+
set -g window-status-current-format "#[fg=colour234,bg=colour39]#[fg=colour25,bg=colour39,noreverse,bold] #I #W #[fg=colour39,bg=colour234,nobold]"
57+
bind b split-window "tmux lsw | percol --initial-index $(tmux lsw | awk '/active.$/ {print NR-1}') | cut -d':' -f 1 | xargs tmux select-window -t"
58+
bind B split-window "tmux ls | percol --initial-index $(tmux ls | awk '/attached.$/ {print NR-1}') | cut -d':' -f 1 | xargs tmux switch-client -t"
59+
60+
bind-key 0 select-window -T -t :0
61+
bind-key 1 select-window -T -t :1
62+
bind-key 2 select-window -T -t :2
63+
bind-key 3 select-window -T -t :3
64+
bind-key 4 select-window -T -t :4
65+
bind-key 5 select-window -T -t :5
66+
bind-key 6 select-window -T -t :6
67+
bind-key 7 select-window -T -t :7
68+
bind-key 8 select-window -T -t :8
69+
bind-key 9 select-window -T -t :9
70+
bind-key S-r command-prompt -I "rename-window "
71+
bind-key l lock-session
72+
bind-key y setw synchronize-panes
73+
74+
bind-key | split-window -h
75+
bind-key \ split-window -h
76+
bind-key - split-window -v
77+
bind-key x kill-pane
78+
bind-key X kill-window
79+
bind-key q confirm-before kill-session
80+
bind-key Q confirm-before kill-server
81+
bind-key , previous-window # <
82+
bind-key . next-window # >
83+
bind-key < swap-window -t :-
84+
bind-key > swap-window -t :+
85+
86+
bind m detach-client -a
87+
88+
set-window-option -g xterm-keys on
89+
#set-option -g lock-command vlock
90+
set-option -g status-interval 0
91+
set-option -g update-environment -r
92+
# vim: set ft=tmux:

inner.conf

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
source ~/.tmux/common.conf
2+
set -g default-shell "/bin/zsh"
3+
set -g prefix C-a
4+
bind-key a send-prefix
5+
bind-key C-a last-window
6+
# Reload key
7+
bind r source-file ~/.tmux/inner.conf
8+
bind C-r command-prompt -I "rename-window "
9+
bind -n M-, swap-window -t -1
10+
bind -n M-. swap-window -t +1
11+
bind -n M-left prev
12+
bind -n M-right next
13+
bind -n M-C new-window
14+
bind -n M-0 select-window -T -t 0
15+
bind -n M-1 select-window -T -t 1
16+
bind -n M-2 select-window -T -t 2
17+
bind -n M-3 select-window -T -t 3
18+
bind -n M-4 select-window -T -t 4
19+
bind -n M-5 select-window -T -t 5
20+
bind -n M-6 select-window -T -t 6
21+
bind -n M-7 select-window -T -t 7
22+
bind -n M-8 select-window -T -t 8
23+
bind -n M-9 select-window -T -t 9
24+
bind -n M-` command-prompt -I '1' -p 'window:' 'select-window -t %1'
25+
bind-key ` command-prompt -I '1' -p 'window:' 'select-window -t %1'
26+
bind-key h new-window 'htop'
27+
bind-key i new-window 'ipython2'
28+
bind-key g new-window 'genius'
29+
bind-key e new-window 'emacsclient -c -nw -f conf ~/'
30+
##CLIPBOARD selection integration
31+
##Requires prefix key before the command key
32+
#Copy tmux paste buffer to CLIPBOARD
33+
bind C-c run "tmux show-buffer | xclip -i -selection clipboard"
34+
#Copy CLIPBOARD to tmux paste buffer and paste tmux paste buffer
35+
bind C-v run "tmux set-buffer -- \"$(xclip -o -selection clipboard)\"; tmux paste-buffer"
36+
37+
#source ~/.tmux/aziz.conf
38+
39+
# vim: set ft=tmux:

inner_test.conf

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
inner.conf

outer.conf

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
source ~/.tmux/common.conf
2+
set -g prefix C-b
3+
bind-key b send-prefix
4+
bind-key C-b last-window
5+
# Reload key
6+
bind r source-file ~/.tmux/outer.conf
7+
8+
bind -n S-left prev
9+
bind -n S-right next
10+
11+
bind -n S-up swap-window -t -1
12+
bind -n S-down swap-window -t +1
13+
14+
bind -n S-M-down new-window
15+
16+
set-option -g status-position top
17+
bind-key C-c command-prompt -p 'title,connectto,command' "new-window -n %% 'AUTOSSH_POLL=30 autossh -M 0 %% -t %% '"
18+
# vim: set ft=tmux:

outer_test.conf

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
outer.conf

setup.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ln -sf ~/.tmux/autossh.py ~/.local/bin/
2+
ln -sf ~/.tmux/tmux.py ~/.local/bin/

0 commit comments

Comments
 (0)