1
0
mirror of https://github.com/samoshkin/tmux-config.git synced 2026-01-03 00:08:01 +00:00

Initial commit

This commit is contained in:
Alexey Samoshkin
2017-11-19 00:36:38 +02:00
commit 943be96ca9
6 changed files with 393 additions and 0 deletions

43
.gitattributes vendored Normal file
View File

@@ -0,0 +1,43 @@
# common settings that generally should always be used with your language specific settings
# Auto detect text files and perform LF normalization
# http://davidlaing.com/2012/09/19/customise-your-gitattributes-to-become-a-git-ninja/
* text=auto
#
# The above will handle all files NOT found below
#
# Documents
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
*.md text
*.adoc text
*.textile text
*.mustache text
*.csv text
*.tab text
*.tsv text
*.sql text
# Graphics
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.tif binary
*.tiff binary
*.ico binary
# SVG treated as an asset (binary) by default. If you want to treat it as text,
# comment-out the following line and uncomment the line after.
*.svg binary
#*.svg text
*.eps binary

28
.gitignore vendored Normal file
View File

@@ -0,0 +1,28 @@
### https://raw.github.com/github/gitignore/8ab86f6bb71e85b5046f1d921bbbe5ceec9063ba/Global/OSX.gitignore
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

37
install.sh Executable file
View File

@@ -0,0 +1,37 @@
#!/bin/bash
set -e
set -u
is_app_installed() {
type "$1" &>/dev/null
}
REPODIR="$(cd "$(dirname "$0")"; pwd -P)"
cd "$REPODIR";
git submodule update --recursive --init --quiet;
if ! is_app_installed tmux; then
printf "$(tput setaf 1)WARNING:$(tput sgr0) \"tmux\" command is not found. \
Install \"tmux\" yourself\n"
fi
# .tmux may already exist (created by tmux plugin manager)
rsync -aq --backup ./tmux/ "$HOME"/.tmux
if [ -e "$HOME/.tmux.conf" ]; then
printf "Found existing .tmux.conf in your \$HOME directory. Will backup it and overwrite with new .tmux.conf file? OK (y/n): "
read -r answer
if echo "$answer" | grep -iq "^n"; then
printf "Install config manually using command below:\n\n";
printf "\t cd && ln -sf .tmux/tmux.conf .tmux.conf\n";
exit 1;
fi
fi
ln -sf --backup=numbered .tmux/tmux.conf "$HOME"/.tmux.conf;
printf "$(tput setaf 2)OK:$(tput sgr0) Files are copied to \$HOME/.tmux and symlink at \$HOME/.tmux.conf is created\n"

47
readme.md Normal file
View File

@@ -0,0 +1,47 @@
My tmux configuration
=====================
Prerequisites
-------------
This repo only installs `tmux.conf` files and related (plugins, scripts, themes, etc). It does not however install tmux, and requires you to do it yourself.
Installation
------------
```
$ git clone <url> <dir>
$ <dir>/install.sh
```
Installation script does following:
1. Init & update git submodules (tmux plugins)
1. Copy files to `$HOME/.tmux` directory, preserving existing file if any (most likely tmux plugins files)
1. Check if you don't have tmux installed and warn you
1. Create symlink at `$HOME/.tmux.conf`, and gently prompts you, if you already have one
Files
-----
<table>
<tr>
<td><code>tmux/tmux.conf</code></td>
<td>Main tmux configuration file (general settings, bindings, plugins, etc)</td>
</tr>
<tr>
<td><code>tmux/theme.conf</code></td>
<td>Appearance settings and status bar setup</td>
</tr>
</table>
Keybindings
-----------
- [ ] TODO: describe keybindin gscheme
Screenshots
-----------
- [ ] TODO: put eye-catching screenshots as soon as I'm done with status bar
Here what you would get:

43
tmux/theme.conf Normal file
View File

@@ -0,0 +1,43 @@
# TODO: extract colour to variables
# Status line
set -g status on
set -g status-interval 10
set -g status-justify centre
set -g status-left-length 70
set -g status-right-length 90
wg_battery='#{battery_status_fg} #{battery_icon} #{battery_percentage} #{battery_remain}'
wg_loadavg='#[fg=colour167,bg=colour235]#( \
uptime | cut -d "," -f 3- | cut -d ":" -f2 | sed -e "s/^[ \t]*//" \
)#[default]'
wg_date='#[fg=colour167,bg=colour235] %h %d %H:%M #[default]'
wg_session='#[fg=green]#S:#[fg=default]#I.#P'
wg_host='#[fg=colour167,bg=colour235]#(echo $USER)@#H#[default]'
wg_is_zoomed='#[fg=colour231,bg=colour04]#{?window_zoomed_flag,[Z],}#[default]'
wg_clients_attached='#[fg=cyan]#{?session_many_attached,~#{session_attached},}#[default]'
# CPU is updated to often, put stress on CPU
# wg_cpu='#{cpu_fg_color}#{cpu_percentage}'
# wg_cpu="#(iostat -c -y 5 1 | tail -n 2 | head -n 1)"
set -g status-style fg=white,bg=colour235
set -g status-right "$wg_loadavg $wg_battery $wg_host $wg_date #{online_status}"
set -g status-left "$wg_session $wg_clients_attached $wg_is_zoomed #{prefix_highlight}"
setw -g window-status-style fg=white,dim
setw -g window-status-current-style fg=brightwhite,nodim,bold,bg=brightred
setw -g window-status-activity-style fg=black,bg=cyan
# Appearence
setw -g pane-active-border-style fg=red
set -g message-style fg=green,bold,bg=black

195
tmux/tmux.conf Normal file
View File

@@ -0,0 +1,195 @@
# ==========================
# === General settings ===
# ==========================
set -g history-limit 20000
set -g buffer-limit 20
set -sg escape-time 1
set -g display-time 2000
set -g allow-rename off
set -g default-terminal "screen"
set -g remain-on-exit off
# Change prefix key to C-a, easier to type, same to "screen"
unbind C-b
set -g prefix C-a
# Set parent terminal title to reflect current window in tmux session
set -g set-titles on
set -g set-titles-string "#I:#W"
# Start index of window/pane with 1, because we're humans, not computers
set -g base-index 1
setw -g pane-base-index 1
# Enable mouse support
set -g mouse on
# ==========================
# === Key bindings ===
# ==========================
# Reload tmux configuration
bind C-r source-file ~/.tmux.conf \; display "Reloaded"
# Rename session and window
unbind "\$"
unbind ,
bind r command-prompt -I "#{window_name}" "rename-window '%%'"
bind R command-prompt -I "#{session_name}" "rename-session '%%'"
# Split panes
unbind %
unbind '"'
bind | split-window -h
bind _ split-window -v
# Select windows
unbind }
unbind {
unbind "'"
unbind n
unbind p
unbind l
unbind M-n
unbind M-p
bind -r < previous-window
bind -r > next-window
bind -r M-< previous-window -a # prev window with alert
bind -r M-> next-window -a # next window with alert
bind -r Tab last-window # cycle thru MRU tabs
bind W command-prompt -p "go to window #" "select-window -t ':%%'"
# Link window
bind L command-prompt -p "Link window from (session:window): " "link-window -s %% -a"
# Swap panes back and forth with 1st pane
# When in main-(horizontal|vertical) layouts, the biggest/widest panel is always @1
bind \ if '[ #{pane_index} -eq 1 ]' \
'swap-pane -s "!"' \
'select-pane -t:.1 ; swap-pane -d -t 1 -s "!"'
# select/swap panes (counter)clockwise
bind -r o select-pane -t :.+
bind -r O select-pane -t :.-
bind -r C-o swap-pane -D
# Kill pane/window/session shortcuts
unbind &
bind x kill-pane
bind C-x confirm-before -p "kill-window #W? (y/n)" kill-window
bind X confirm-before -p "kill-session #S? (y/n)" kill-session
# Merge session with another one (e.g. move all windows)
# If you use adhoc 1-window sessions, and you want to preserve session upon exit
# but don't want to create a lot of small unnamed 1-window sessions around
# move all windows from current session to main named one (dev, work, etc)
bind C-u command-prompt -p "Session to merge with: " \
"run-shell 'yes | head -n #{session_windows} | xargs -I {} -n 1 tmux movew -t %%'"
# Detach from session
bind d detach
bind D if -F '#{session_many_attached}' \
'confirm-before -p "Detach other clients? (y/n)" "detach -a"' \
'display "Session has only 1 client attached"'
# ==================================================
# === Window monitoring for activity and silence ===
# ==================================================
bind m setw monitor-activity \; display-message 'Monitor window activity [#{?monitor-activity,ON,OFF}]'
bind M if -F '#{monitor-silence}' \
'setw monitor-silence 0 ; display-message "Monitor window silence [OFF]"' \
'command-prompt -p "Monitor silence: interval (s)" "setw monitor-silence %%"'
# Activity bell and whistles
set -g visual-activity on
# TODO: Does not work as well, check on newer versions
# set -g visual-silence on
# BUG: bell-action other ignored · Issue #1027 · tmux/tmux · GitHub - https://github.com/tmux/tmux/issues/1027
# set -g visual-bell on
# setw -g bell-action other
# ================================
# === Copy and scroll ===
# ================================
unbind "#" # list-buffer
unbind = # choose-buffer
unbind ] # paste-buffer
# Prefer vi style key table
setw -g mode-keys vi
# trigger copy mode by pressing PageUp key w/o prepending it with prefix key
bind -n PageUp copy-mode
bind Escape copy-mode
bind p paste-buffer
bind C-p choose-buffer
# Scroll up/down by 1 line, half screen, whole screen
bind -T copy-mode-vi M-Up send-keys -X scroll-up
bind -T copy-mode-vi M-Down send-keys -X scroll-down
bind -T copy-mode-vi M-PageUp send-keys -X halfpage-up
bind -T copy-mode-vi M-PageDown send-keys -X halfpage-down
bind -T copy-mode-vi PageDown send-keys -X page-down
bind -T copy-mode-vi PageUp send-keys -X page-up
# When scrolling with mouse wheel, reduce number of scrolled rows per tick to "2" (default is 5)
bind -T copy-mode-vi WheelUpPane select-pane \; send-keys -X -N 2 scroll-up
bind -T copy-mode-vi WheelDownPane select-pane \; send-keys -X -N 2 scroll-down
# Do not copy selection and cancel copy mode on drag end event
# More iTerm style selection: select, then need to mouse click to copy to buffer
unbind -T copy-mode-vi MouseDragEnd1Pane
bind -T copy-mode-vi MouseDown1Pane select-pane \; send-keys -X copy-selection
# ===================================
# === Appearence and status bar ===
# ===================================
# TODO: Not ready yet
# source ~/.tmux/theme.conf
# ============================
# === Hooks ===
# ============================
# Prompt to rename window right after it's created
set-hook -g after-new-window 'command-prompt -I "#{window_name}" "rename-window '%%'"'
# ============================
# === Plugins ===
# ============================
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-battery'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @plugin 'tmux-plugins/tmux-online-status'
set -g @plugin 'tmux-plugins/tmux-sidebar'
set -g @plugin 'tmux-plugins/tmux-copycat'
set -g @plugin 'tmux-plugins/tmux-open'
# Plugin properties
set -g @batt_remain_short true
set -g @prefix_highlight_show_copy_mode 'on'
set -g @prefix_highlight_output_prefix '['
set -g @prefix_highlight_output_suffix ']'
set -g @online_icon "#[fg=green]●#[default]"
set -g @offline_icon "#[fg=red]●#[default]"
set -g @sidebar-tree 't'
set -g @sidebar-tree-focus 'T'
set -g @sidebar-tree-command 'tree -C'
set -g @open-S 'https://www.google.com/search?q='
# Run all plugins' scripts
run '~/.tmux/plugins/tpm/tpm'