-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.tmux.conf
More file actions
216 lines (180 loc) · 7.12 KB
/
Copy path.tmux.conf
File metadata and controls
216 lines (180 loc) · 7.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# Pretty colors
set -g default-terminal "screen-256color"
# If on OSX, also use the other tmux.conf
# if-shell 'test "$(uname)" = "Darwin"' 'source ~/.tmux-osx.conf'
# bigger history limit, default: 2000
set-option -g history-limit 100000
# Longer display time on Prefix q
set -g display-panes-time 2000
# fix slow esc on neovim
set -sg escape-time 0
# Clear history with ^k
#bind -n C-k send-keys -R \; clear-history
# Clear history for gnome
# On gnome Alt-Ctrl-l clear history on terminal
bind -n C-y send-keys M-C-L \;
# ##########################################
# # General #
# ##########################################
#
# set -s escape-time 0
#
# # history
# bind-key \ send-keys -R \; clear-history
#
# # mode
# setw -g mode-keys vi
#
# # prefix
unbind C-b
set -g prefix `
bind ` send-prefix
#
# # prompt
# bind : command-prompt
#
# # reload
# bind r source-file ~/.tmux.conf
#
# ##########################################
# # Windows #
# ##########################################
#
# # first pane has index of 1 instead of 0
set -g base-index 1
set-option -g renumber-windows on
#
# # resize
# bind < resize-pane -L 5
# bind > resize-pane -R 5
# bind { resize-pane -U 5
# bind } resize-pane -D 5
#
# # split
# bind s split-window -v
# bind v split-window -h
#
# # windows titles
# set -g status-left-length 50
#
#
# ##########################################
# # Panes #
# ##########################################
#
# # first session has index of 1 instead of 0
set-window-option -g pane-base-index 1
#
# # switch
# bind h select-pane -L
# bind j select-pane -D
# bind k select-pane -U
# bind l select-pane -R
#Pane colours
# set inactive/active window styles
set -g window-style 'fg=colour247,bg=colour236'
set -g window-active-style 'fg=colour250,bg=black'
#pane border
# set -g pane-border-bg colour235
# set -g pane-border-fg colour238
# set -g pane-active-border-bg colour236
# set -g pane-active-border-fg colour51
# Transparent background
set -g pane-active-border-style bg=color0,fg=cyan
# set -g pane-active-border-style bg=default,fg=cyan
set -g pane-border-style bg=color0
set-window-option -g window-active-style bg=terminal
set-window-option -g window-style bg=terminal
# copy mode selection as in vim
set-window-option -g mode-keys vi
bind-key -T copy-mode-vi 'v' send-keys -X begin-selection
# bind-key -T copy-mode-vi 'y' send-keys -X copy-selection
# clear
bind -n C-l send-keys C-l \; run 'sleep 0.1' \; clear-history
# refresh
bind-key r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded"
# movement
# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
bind-key -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
bind-key -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
bind-key -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
# bind-key -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l"
bind-key -T copy-mode-vi C-h select-pane -L
bind-key -T copy-mode-vi C-j select-pane -D
bind-key -T copy-mode-vi C-k select-pane -U
bind-key -T copy-mode-vi C-l select-pane -R
# bind-key -T copy-mode-vi C-\ select-pane -l
# git
# bind '"\C-g\C-f": "$(fbr)\e\C-e"'
# no more cut session names
set-option -g status-left-length 15
# TODO show battery %
# Format date on status bar
set-option -g status-right " #(date '+%a, %b %d - %I:%M') "
# Splitting panes will keep same path
bind-key '"' split-window -v -c '#{pane_current_path}'
bind-key '%' split-window -h -c '#{pane_current_path}'
# Creating windows will use current path
bind c new-window -c '#{pane_current_path}'
# Resize panes
bind -n C-Left resize-pane -L 10
bind -n C-Right resize-pane -R 10
bind -n C-Down resize-pane -D 5
bind -n C-Up resize-pane -U 5
# Move pane to new window
# bind-key b break-pane -d
# Create new session and open .timux file
# bind-key S new-session -c '#{pane_current_path}' 'tmux source .timux'
# run-shell ~/workspaces/tmux_plugins/tmux-resurrect/resurrect.tmux
# ##########################################
# # Popups #
# ##########################################
bind T display-menu -T "#[align=centre]Dotfiles" -x C -y C \
"dotfiles" d "display-popup -w 90% -h 90% -d "~/workspaces/dot-files" -E 'nvim .'" \
"bash" b "display-popup -w 90% -h 90% -E 'nvim ~/.bashrc'" \
"neovim" n "display-popup -w 90% -h 90% -E 'nvim ~/workspaces/dot-files/init.vim'" \
"tmux" t "display-popup -w 90% -h 90% -E 'nvim ~/workspaces/dot-files/.tmux.conf" \
"hyprland" h "display-popup -w 90% -h 90% -E 'nvim ~/.config/hypr/hyprland.conf" \
"waybar" w "display-popup -w 90% -h 90% -E 'nvim ~/.config/waybar/config.jsonc" \
"irbrc" i "display-popup -w 90% -h 90% -E 'nvim ~/workspaces/dot-files/.irbrc" \
"Exit" q ""
bind C-y display-popup \
-d "#{pane_current_path}" \
-w 90% \
-h 90% \
-E "lazygit"
bind C-t display-popup \
-d "#{pane_current_path}" \
-w 90% \
-h 90% \
-E "bash"
# bind-key -T copy-mode-vi i send -X copy-pipe-and-cancel "sh -c 'tmux display-popup \"| awk '{ for(i=1;i<=NF;i++) if($i ~ /^[[:alnum:]]+$/) { print $i; break } }'\"'"
# bind-key -T copy-mode-vi y send -X copy-pipe-and-cancel "sh -c 'tmux display-popup -E \"cat\"'"
# bind-key -T copy-mode-vi i send -X copy-pipe-and-cancel "sh -c 'tmp=$(mktemp); cat > $tmp; tmux display-popup -E \"vim $tmp\"'"
# bind-key -T copy-mode-vi i send -X copy-pipe "sh -c 'awk \'{ print \$1 }\' | tmux display-popup \"cat\"'"
# bind-key -T copy-mode-vi y send -X copy-pipe-and-cancel "sh -c 'awk \'{ print \$1 }\' | tmux display-popup \"cat\"'"
# bind-key -T copy-mode-vi i send -X copy-pipe "sh -c 'awk \'{ print \$1 }\' | tmux display-popup \"cat\"'"
# bind-key -T copy-mode-vi 'i' display-popup \
# -d "#{pane_current_path}" \
# -w 90% \
# -h 90% \
# -E "git show $(wl-paste | awk '{ for(i=1;i<=NF;i++) if($i ~ /^[[:alnum:]]+$/) { print $i; break } }') && read"
bind-key -T copy-mode-vi y send -X copy-pipe "read sha; tmux display-popup -d \"#{pane_current_path}\" -w 90% -h 90% -E \"git show --color=always \$sha | less -R\""
# TODO: fix
# bind-key -T copy-mode-vi y send -X copy-pipe "read sha; tmux display-popup -d \"#{pane_current_path}\" -w 90% -h 90% -E \"awk '{ for(i=1;i<=NF;i++) if($i ~ /^[[:alnum:]]+$/) { print $i; break } } \$sha' | xargs git show --color=always | less -R\""
# git log --oneline | awk 'NR==1 {print $1}' | xargs git show
# tmux display-popup -d "#{pane_current_path}" -E "git log --oneline | fzf | awk '{print \$1}' | xargs git show --color=always | less -R"
bind C-i display-popup \
-d "#{pane_current_path}" \
-w 90% \
-h 90% \
-E "git show $(wl-paste) && read"
# -E "git show $(wl-paste | awk '{ for(i=1;i<=NF;i++) if($i ~ /^[[:alnum:]]+$/) { print $i; break } }') && read"
# awk for extracting commit's SHA from git log
# awk '{ for(i=1;i<=NF;i++) if($i ~ /^[[:alnum:]]+$/) { print $i; break } }'
# Credits
# https://github.com/ericmckevitt/Dotfiles/