diff --git a/tmux.conf b/tmux.conf index fd526c81..cfd5a023 100644 --- a/tmux.conf +++ b/tmux.conf @@ -8,8 +8,8 @@ set -g renumber-windows on setw -g automatic-rename on # Remove the delay set -s escape-time 0 -# 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 +# 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 off # go zsh, go @@ -26,35 +26,43 @@ set-option -g default-command "reattach-to-user-namespace -l zsh" set -g prefix C-a unbind C-b # Restore go-to-start-of-line shortcut -bind a send-prefix +bind C-a send-prefix # Go to last active window -bind-key C-a last-window +bind-key a last-window # reload config without killing server -bind R source-file ~/.tmux.conf \; display-message " Config reloaded..". -# Better splitting keybinds -unbind % -bind H split-window -v -unbind '"' -bind V split-window -h +bind r source-file ~/.tmux.conf \; display-message " Config reloaded..". # set vi keys setw -g mode-keys vi unbind [ bind Escape copy-mode unbind p bind p paste-buffer - bind-key -t vi-copy 'v' begin-selection bind-key -t vi-copy 'y' copy-pipe "reattach-to-user-namespace pbcopy" unbind -t vi-copy Enter bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy" +## Pane management ##### +# Better splitting keybinds +unbind % +unbind '"' +bind H split-window -v +bind V split-window -h + +# Navigate between panes bind h select-pane -L bind j select-pane -D bind k select-pane -U bind l select-pane -R bind-key -r C-h select-window -t :- bind-key -r C-l select-window -t :+ +bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|vim?)(diff)?$' && tmux send-keys C-h) || tmux select-pane -L" +bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|vim?)(diff)?$' && tmux send-keys C-j) || tmux select-pane -D" +bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|vim?)(diff)?$' && tmux send-keys C-k) || tmux select-pane -U" +bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|vim?)(diff)?$' && tmux send-keys C-l) || tmux select-pane -R" +bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|vim?)(diff)?$' && tmux send-keys 'C-\\') || tmux select-pane -l" + # after copying to a tmux buffer, hit y again to copy to clipboard bind y run "tmux save-buffer - | reattach-to-user-namespace pbcopy" # quick view of processes @@ -65,6 +73,8 @@ bind-key -n C-left prev ## Looks ######################## +# make tmux display things in 256 colors +set -g default-terminal "screen-256color" # default statusbar colors set-option -g status-bg '#333333' set-option -g status-fg yellow #yellow @@ -91,8 +101,8 @@ set-window-option -g clock-mode-colour green #green ## Status bar ################### -set-option -g status-justify left +set-option -g status-justify left set-option -g status-right-length 60 set-option -g status-left-length 60 -set-option -g status-left '#[bg=blue] #[fg=white]#[bold]#S #[default]' -set-option -g status-right '#[bg=#383838] #(whoami)@#H' +set-option -g status-left '#[bg=#252525] #[fg=white]#[bold]#S #[default]' +set-option -g status-right '#[bg=#383838] #(whoami) : #H ' diff --git a/zsh/aliases b/zsh/aliases index f6c0ca24..386376b2 100644 --- a/zsh/aliases +++ b/zsh/aliases @@ -13,6 +13,17 @@ if command_exists 'git'; then } fi +# Tmux +if command_exists 'tmux'; then + alias t='tmux new -s x || tmux attach -t x' + alias tl='tmux list-sessions' + alias ts='tmux switch' + + function tmux-send { + tmux send-keys -s "x" $1 Enter + } +fi + # OS-specific aliases if [[ "$OSTYPE" == darwin* ]]; then alias b='brew' @@ -44,7 +55,7 @@ alias py3='python3' [ -e /Applications/love.app ] && alias love="/Applications/love.app/Contents/MacOS/love" # Shell conveniences -alias \\q='exit' +alias q='exit' alias sha1='openssl sha1' alias header='curl -I' @@ -53,7 +64,7 @@ alias header='curl -I' alias wget='wget -c' # Lets us sudo aliases -alias sudo='sudo ' +# alias sudo='sudo ' # Make a directory and change to it function mkd { mkdir "$@" && cd "$@" } diff --git a/zsh/config b/zsh/config index 1d8e5eb7..fe03dfe1 100644 --- a/zsh/config +++ b/zsh/config @@ -10,6 +10,6 @@ zle -N edit-command-line bindkey -v bindkey '^f' edit-command-line -bindkey '^w' backward-kill-word -bindkey '^a' beginning-of-line -bindkey '^e' end-of-line +bindkey -M viins '^w' backward-kill-word +bindkey -M viins '^a' beginning-of-line +bindkey -M viins '^e' end-of-line diff --git a/zsh/preztorc b/zsh/preztorc index 4564e778..ddede30a 100644 --- a/zsh/preztorc +++ b/zsh/preztorc @@ -19,19 +19,19 @@ zstyle ':prezto:*:*' color 'yes' # Set the Prezto modules to load (browse modules). # The order matters. zstyle ':prezto:load' pmodule \ - 'environment' \ - 'terminal' \ - 'editor' \ - 'opp' \ - 'history' \ - 'history-substring-search' \ - 'directory' \ - 'spectrum' \ - 'utility' \ - 'completion' \ - 'prompt' \ - 'git' \ - 'osx' + 'environment' \ + 'terminal' \ + 'editor' \ + 'opp' \ + 'history' \ + 'history-substring-search' \ + 'directory' \ + 'spectrum' \ + 'utility' \ + 'completion' \ + 'prompt' \ + 'git' \ + 'osx' # Editor @@ -109,4 +109,4 @@ zstyle ':prezto:module:terminal' auto-title 'yes' # zstyle ':prezto:module:tmux:auto-start' local 'yes' # Auto start a session when Zsh is launched in a SSH connection. -# zstyle ':prezto:module:tmux:auto-start' remote 'yes' +# zstyle ':prezto:module:tmux:auto-start' remote 'yes' \ No newline at end of file