dotfiles

Obligatory dotfiles repo
git clone git://git.danielmoch.com/dotfiles.git
Log | Files | Refs

commit ba6cc6947aa3449e53ac3fb4316179eca046428b
parent 0ae23e43b10652817a7a8edd859ce8cb83d64af2
Author: Daniel Moch <daniel@danielmoch.com>
Date:   Thu,  1 Feb 2018 05:23:42 -0500

Refactor Tmux config

1. Combine theme.sh into .tmux.conf
2. Move tmux-copy and tmux-paste into my
3. Move battery indicator into .local/lib
4. Remove unused scripts

Diffstat:
D.config/tmux/bin/login-shell | 10----------
D.config/tmux/bin/tm | 30------------------------------
D.config/tmux/bin/tmux-copy.sh | 16----------------
D.config/tmux/bin/tmux-paste.sh | 16----------------
D.config/tmux/theme.sh | 63---------------------------------------------------------------
M.local/bin/my | 34++++++++++++++++++++++++++++++++++
R.config/tmux/bin/battery_indicator.sh -> .local/lib/tmux/battery_indicator.sh | 0
M.tmux.conf | 177++++++++++++++++++++++++++++++++++++++++++-------------------------------------
8 files changed, 128 insertions(+), 218 deletions(-)

diff --git a/.config/tmux/bin/login-shell b/.config/tmux/bin/login-shell @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -shell=$(basename "$SHELL") - -# check if reattach-to-user-namespace is available -if [ -n "$(command -v reattach-to-user-namespace)" ]; then - reattach-to-user-namespace -l "$shell" -else - exec "$shell -l" -fi diff --git a/.config/tmux/bin/tm b/.config/tmux/bin/tm @@ -1,30 +0,0 @@ -#!/bin/sh - -# abort if we're already inside a TMUX session -[ "$TMUX" == "" ] || exit 0 -# startup a "default" session if non currently exists -# tmux has-session -t _default || tmux new-session -s _default -d - -# present menu for user to choose which workspace to open -PS3="Please choose your session: " -options=($(tmux list-sessions -F "#S" 2>/dev/null) "New Session" "zsh") -echo "Available sessions" -echo "------------------" -echo " " -select opt in "${options[@]}" -do - case $opt in - "New Session") - read -p "Enter new session name: " SESSION_NAME - tmux new -s "$SESSION_NAME" - break - ;; - "zsh") - zsh --login - break;; - *) - tmux attach-session -t $opt - break - ;; - esac -done diff --git a/.config/tmux/bin/tmux-copy.sh b/.config/tmux/bin/tmux-copy.sh @@ -1,16 +0,0 @@ -#!/usr/bin/env bash -uname=$(uname -s) - -case $uname in - *Darwin*) - reattach-to-user-namespace pbcopy - ;; - *CYGWIN*) - cat > /dev/clipboard - ;; - *Linux*) - xclip -selection clipboard - ;; - *) - return -esac diff --git a/.config/tmux/bin/tmux-paste.sh b/.config/tmux/bin/tmux-paste.sh @@ -1,16 +0,0 @@ -#!/usr/bin/env bash -uname=$(uname -s) - -case $uname in - *Darwin*) - reattach-to-user-namespace pbpaste - ;; - *CYGWIN*) - cat /dev/clipboard - ;; - *Linux*) - xclip -o - ;; - *) - return -esac diff --git a/.config/tmux/theme.sh b/.config/tmux/theme.sh @@ -1,63 +0,0 @@ -#### COLOUR - -tm_color_active=colour67 -tm_color_inactive=colour242 -tm_color_feature=colour131 -tm_active_border_color=colour67 - -set -g status-left-length 32 -set -g status-right-length 150 -set -g status-interval 5 - - -# default statusbar colors -# set-option -g status-bg colour0 -set-option -g status-fg $tm_color_active -set-option -g status-bg default -set-option -g status-attr default - -# default window title colors -set-window-option -g window-status-fg $tm_color_inactive -set-window-option -g window-status-bg default -set -g window-status-format "#I #W" - -# active window title colors -set-window-option -g window-status-current-fg $tm_color_active -set-window-option -g window-status-current-bg default -set-window-option -g window-status-current-format "#[bold]#I #W" - -# pane border -set-option -g pane-border-fg $tm_color_inactive -set-option -g pane-active-border-fg $tm_active_border_color - -# message text -set-option -g message-bg default -set-option -g message-fg $tm_color_active - -# pane number display -set-option -g display-panes-active-colour $tm_color_active -set-option -g display-panes-colour $tm_color_inactive - -# clock -set-window-option -g clock-mode-colour $tm_color_active - -tm_weather="#[fg=$tm_color_feature]#(cat ~/.config/forecastio/current_forecast.txt)" -tm_battery="#(~/.config/tmux/bin/battery_indicator.sh)" - -tm_date="#[fg=$tm_color_inactive] %R %d %b" -tm_host="#[fg=$tm_color_feature,bold]#h" -tm_session_name="#[fg=$tm_color_feature,bold]\[#S\]" - -set -g status-left $tm_session_name' ' -set -g status-right $tm_battery' '$tm_weather' '$tm_date' '$tm_host - -set-environment -gu tm_color_active -set-environment -gu tm_color_inactive -set-environment -gu tm_color_feature -set-environment -gu tm_weather -set-environment -gu tm_battery -set-environment -gu tm_date -set-environment -gu tm_host -set-environment -gu tm_session_name -set-environment -gu tm_active_border_color -# vim: ft=tmux diff --git a/.local/bin/my b/.local/bin/my @@ -285,4 +285,38 @@ case $command in exit 1 fi ;; + copy) + uname=`uname -s` + + case $uname in + *Darwin*) + reattach-to-user-namespace pbcopy + ;; + *CYGWIN*) + cat > /dev/clipboard + ;; + *Linux*) + xclip -selection clipboard + ;; + *) + return + esac + ;; + paste) + uname=`uname -s` + + case $uname in + *Darwin*) + reattach-to-user-namespace pbpaste + ;; + *CYGWIN*) + cat /dev/clipboard + ;; + *Linux*) + xclip -o + ;; + *) + return + esac + ;; esac diff --git a/.config/tmux/bin/battery_indicator.sh b/.local/lib/tmux/battery_indicator.sh diff --git a/.tmux.conf b/.tmux.conf @@ -1,120 +1,131 @@ # # ~/.tmux.conf # -set -g history-limit 20000 - -# Set default-command and default-shell to avoid spawning login shells -set -g default-command $SHELL -set -g default-shell $SHELL - -# Turn off escape delay, which is very annoying in Vim -set -s escape-time 0 - -# automatically renumber tmux windows -set -g renumber-windows on - -# Vi mode -set-window-option -g mode-keys vi - -# unbind default prefix and set it to Ctrl+a -unbind C-b -set -g prefix C-a -bind C-a send-prefix - -# Activity Monitoring -setw -g monitor-activity off -setw -g monitor-bell on -set -g visual-activity off -set -g bell-action any -set -g visual-bell on - -# Rather than constraining window size to the maximum size of any client -# connected to the *session*, constrain window size to the maximum size of any -# client connected to *that window*. Much more reasonable. -setw -g aggressive-resize on - -# make window/pane index start with 1 -set -g base-index 1 -setw -g pane-base-index 1 +# {{{ General Options +set-option -g history-limit 20000 +set-option -g default-command $SHELL +set-option -g default-shell $SHELL +set-option -s escape-time 0 +set-option -g renumber-windows on +set-option -g prefix C-a +set-option -g visual-activity off +set-option -g bell-action any +set-option -g visual-bell on +set-option -g base-index 1 set-option -g set-titles on set-option -g set-titles-string "#T - #W" - set-option -g default-terminal "tmux-256color" -# set-window-option -g automatic-rename on +set-window-option -g mode-keys vi +set-window-option -g monitor-activity off +set-window-option -g monitor-bell on +set-window-option -g aggressive-resize on +set-window-option -g pane-base-index 1 +set-window-option -g mouse on +set-window-option -g mode-keys vi +# }}} -###################### -#### Key Bindings #### -###################### +# {{{ Key Bindings +unbind C-b +unbind Up +unbind Down +unbind [ +unbind p -# reload config file +bind C-a send-prefix bind r source-file ~/.tmux.conf \; display "Config Reloaded!" - -# quickly open a new window -bind N new-window - -# split window and fix path for tmux 1.9 bind | split-window -h -c "#{pane_current_path}" bind - split-window -v -c "#{pane_current_path}" - -# synchronize all panes in a window -bind y setw synchronize-panes - -# pane movement shortcuts +bind y set-window-option synchronize-panes bind h select-pane -L bind j select-pane -D bind k select-pane -U bind l select-pane -R - bind -r C-h select-window -t :- bind -r C-l select-window -t :+ - -# Resize pane shortcuts bind -r H resize-pane -L 10 bind -r J resize-pane -D 10 bind -r K resize-pane -U 10 bind -r L resize-pane -R 10 - -# Reorder the current window left and right bind C-h swap-window -t -1 bind C-l swap-window -t +1 - -# enable mouse support for switching panes/windows -setw -g mouse on -# set-option -g -q mouse on - bind -T root PPage if-shell -F "#{alternate_on}" "send-keys PPage" "copy-mode -e; send-keys PPage" bind -T copy-mode-vi PPage send -X page-up bind -T copy-mode-vi NPage send -X page-down - bind -T root WheelUpPane if-shell -F -t = "#{alternate_on}" "select-pane -t =; send-keys -M" "select-pane -t =; copy-mode -e; send-keys -M" bind -T root WheelDownPane if-shell -F -t = "#{alternate_on}" "select-pane -t =; send-keys -M" "select-pane -t =; send-keys -M" bind -T copy-mode-vi WheelUpPane send -X halfpage-up bind -T copy-mode-vi WheelDownPane send -X halfpage-down - -# maximizing and restoring windows -unbind Up bind Up new-window -d -n fullscreen \; swap-pane -s fullscreen.1 \; select-window -t fullscreen -unbind Down bind Down last-window \; swap-pane -s fullscreen.1 \; kill-window -t fullscreen - -# set vi mode for copy mode -setw -g mode-keys vi -# more settings to make copy-mode more vim-like -unbind [ bind Escape copy-mode -unbind p bind p paste-buffer bind -T copy-mode-vi 'v' send -X begin-selection -bind -T copy-mode-vi 'y' send -X copy-pipe "~/.config/tmux/bin/tmux-copy.sh" - -# Buffers to/from Mac clipboard, yay tmux book from pragprog -bind C-c run "tmux save-buffer - | ~/.config/tmux/bin/tmux-copy.sh" -bind C-v run "tmux set-buffer \"$(~/.config/tmux/bin/tmux-paste.sh)\"; tmux paste-buffer" - -############################## -### Color & Style Settings ### -############################## - -source ~/.config/tmux/theme.sh +bind -T copy-mode-vi 'y' send -X copy-pipe "my copy" +bind C-c run "tmux save-buffer - | my copy" +bind C-v run "tmux set-buffer \"`my paste`\"; tmux paste-buffer" +# }}} + +# {{{ Theme +tm_color_active=colour67 +tm_color_inactive=colour242 +tm_color_feature=colour131 +tm_active_border_color=colour67 + +set -g status-left-length 32 +set -g status-right-length 150 +set -g status-interval 5 + + +# default statusbar colors +# set-option -g status-bg colour0 +set-option -g status-fg $tm_color_active +set-option -g status-bg default +set-option -g status-attr default + +# default window title colors +set-window-option -g window-status-fg $tm_color_inactive +set-window-option -g window-status-bg default +set -g window-status-format "#I #W" + +# active window title colors +set-window-option -g window-status-current-fg $tm_color_active +set-window-option -g window-status-current-bg default +set-window-option -g window-status-current-format "#[bold]#I #W" + +# pane border +set-option -g pane-border-fg $tm_color_inactive +set-option -g pane-active-border-fg $tm_active_border_color + +# message text +set-option -g message-bg default +set-option -g message-fg $tm_color_active + +# pane number display +set-option -g display-panes-active-colour $tm_color_active +set-option -g display-panes-colour $tm_color_inactive + +# clock +set-window-option -g clock-mode-colour $tm_color_active + +tm_weather="#[fg=$tm_color_feature]#(cat ~/.config/forecastio/current_forecast.txt)" +tm_battery="#(~/.local/lib/tmux/battery_indicator.sh)" + +tm_date="#[fg=$tm_color_inactive] %R %d %b" +tm_host="#[fg=$tm_color_feature,bold]#h" +tm_session_name="#[fg=$tm_color_feature,bold]\[#S\]" + +set -g status-left $tm_session_name' ' +set -g status-right $tm_battery' '$tm_weather' '$tm_date' '$tm_host + +set-environment -gu tm_color_active +set-environment -gu tm_color_inactive +set-environment -gu tm_color_feature +set-environment -gu tm_weather +set-environment -gu tm_battery +set-environment -gu tm_date +set-environment -gu tm_host +set-environment -gu tm_session_name +set-environment -gu tm_active_border_color +# }}}