Created
January 27, 2015 17:54
-
-
Save Apsu/ba2055d69643b6c4ac29 to your computer and use it in GitHub Desktop.
vi{,m} environment config files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Prefix and cycle | |
set-option -g prefix C-\\ | |
bind C-\ last-window | |
# Reload config | |
bind r source-file ~/.tmux.conf | |
# Mouse mode | |
set -g mode-mouse on | |
set -g mouse-resize-pane on | |
set -g mouse-select-pane on | |
set -g mouse-select-window on | |
# emacs copy-mode | |
#setw -g mode-keys emacs | |
# vi copy-mode | |
setw -g mode-keys vi | |
# Add expected vim keybindings | |
bind-key -t vi-copy 'v' begin-selection | |
# Smart pane switching with awareness of vim splits | |
bind -n M-h run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys C-h) || tmux select-pane -L" | |
bind -n M-j run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys C-j) || tmux select-pane -D" | |
bind -n M-k run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys C-k) || tmux select-pane -U" | |
bind -n M-l run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys C-l) || tmux select-pane -R" | |
#bind -n M-B run "(tmux display-message -p '#{pane_current_command}' | grep -iq emacs && tmux send-keys M-B) || tmux select-pane -L" | |
#bind -n M-F run "(tmux display-message -p '#{pane_current_command}' | grep -iq emacs && tmux send-keys M-F) || tmux select-pane -R" | |
#bind -n M-P run "(tmux display-message -p '#{pane_current_command}' | grep -iq emacs && tmux send-keys M-P) || tmux select-pane -U" | |
#bind -n M-N run "(tmux display-message -p '#{pane_current_command}' | grep -iq emacs && tmux send-keys M-N) || tmux select-pane -D" | |
#bind -n M-B select-pane -L | |
#bind -n M-F select-pane -R | |
#bind -n M-P select-pane -U | |
#bind -n M-N select-pane -D | |
# Quick copy-mode access | |
bind -n M-` copy-mode | |
# New window | |
bind -n M-t new-window | |
# Window naviation | |
bind -n M-n next-window | |
bind -n M-p previous-window | |
# Move windows | |
bind -n M-N swap-window -t +1 | |
bind -n M-P swap-window -t -1 | |
# Kill pane | |
bind -n M-x kill-pane | |
# Break pane to new window | |
bind -n M-> break-pane | |
# Merge pane with previous window | |
bind -n M-< join-pane -t -1 | |
# Copy to clipboard | |
#bind -t vi-copy Enter copy-pipe 'pbcopy' | |
#bind -t vi-copy y copy-pipe 'pbcopy' | |
bind -t vi-copy Enter copy-pipe 'reattach-to-user-namespace pbcopy' | |
bind -t vi-copy y copy-pipe 'reattach-to-user-namespace pbcopy' | |
#bind -t emacs-copy M-w copy-pipe 'reattach-to-user-namespace pbcopy' | |
#bind -t emacs-copy Enter copy-pipe 'reattach-to-user-namespace pbcopy' | |
# FIXME: Don't seem to need this anymore | |
# Reattach namespace for clipboard access | |
set -g default-command "reattach-to-user-namespace -l /usr/local/bin/zsh" | |
# Move panes | |
bind -n M-, rotate-window -U | |
bind -n M-. rotate-window -D | |
# Cycle layouts | |
bind -n M-Space next-layout | |
# Split windows into panes | |
bind -n M-_ split-window | |
bind -n M-| split-window -h | |
# Zoom! | |
bind -n M-z resize-pane -Z | |
# Parse URLs for launching | |
#bind -n M-u capture-pane \; save-buffer /tmp/tmux-buffer \; new-window -n urlscan '$SHELL -c "urlscan -b < /tmp/tmux-buffer"' | |
# QUIET!! | |
set -g quiet on | |
# UTF8 is great | |
set -g status-utf8 on | |
# Less delay for commands; might disable complex chords | |
set -s escape-time 0 | |
# Clamp TERM | |
set -g default-terminal "screen-256color" | |
# Show me your history | |
set -g history-limit 10000 | |
# Set title | |
set -g set-titles on | |
set -g set-titles-string "#T" | |
# Renumber windows on deletion | |
set -g renumber-windows on | |
# Tweak pane borders a smidge | |
set -g pane-active-border-fg "#ffffff" | |
set -g pane-border-fg "#555555" | |
# Set default shell | |
set -g default-shell "/usr/local/bin/zsh" | |
# Powerline ahoy! | |
source '/usr/local/lib/python2.7/site-packages/powerline/bindings/tmux/powerline.conf' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" | |
" Pathogen | |
" | |
execute pathogen#infect() | |
" | |
" Powerline | |
" | |
set rtp+=/usr/local/lib/python2.7/site-packages/powerline/bindings/vim | |
" | |
" General | |
" | |
set laststatus=2 " Always display the statusline in all windows | |
set noshowmode " Hide the default mode text (e.g. -- INSERT -- below the statusline) | |
set list " Show extra whitespace | |
set switchbuf=usetab,newtab " Useful tab/buffer behavior | |
set linebreak " Break lines at word (requires Wrap lines) | |
set showbreak=+++ " Wrap-broken line prefix | |
set textwidth=100 " Line wrap (number of cols) | |
set showmatch " Highlight matching brace | |
"set relativenumber " Relative line numbers; with absolute sets hybrid | |
"set number " Absolute line numbers; with relative sets hybrid | |
set hlsearch " Highlight all search results | |
set smartcase " Enable smart-case search | |
set ignorecase " Always case-insensitive | |
set incsearch " Searches for strings incrementally | |
set autoindent " Auto-indent new lines | |
set expandtab " Use spaces instead of tabs | |
set shiftwidth=2 " Number of auto-indent spaces | |
set smartindent " Enable smart-indent | |
set smarttab " Enable smart-tabs | |
set softtabstop=2 " Number of spaces per Tab | |
set autochdir " Change working directory to open buffer | |
set undolevels=1000 " Number of undo levels | |
set backspace=indent,eol,start " Backspace behaviour | |
set background=dark " Brightens various things accordingly | |
set clipboard+=unnamed " Use system clipboard | |
set splitbelow " Open vertical splits below | |
set splitright " Open horizontal splits right | |
" GUI settings | |
set guifont=Source\ Code\ Pro\ for\ Powerline | |
set guioptions=egm " Disable scrollbars | |
" Set paste mode on Cmd+V and paste from clipboard | |
imap <D-V> ^O""p | |
" Leader | |
let mapleader = "," | |
" Git | |
nnoremap <Leader>gco :Git checkout | |
nnoremap <Leader>gc :Gcommit<CR> | |
nnoremap <Leader>gp :Git push<CR> | |
nnoremap <Leader>gs :Gstatus<CR> | |
nnoremap <Leader>gw :Gw<CR> | |
nnoremap <Leader>gd :Gdiff<CR> | |
nnoremap <Leader>gl :Glog<CR> | |
" Read/write | |
nnoremap <Leader>w :w<CR> | |
nnoremap <Leader>W :w | |
nnoremap <Leader>e :e | |
" Quit | |
nnoremap <Leader>q :q<CR> | |
nnoremap <Leader>Q :qa<CR> | |
" Exec | |
nnoremap <Leader>x :w<CR>:!./%<CR> | |
" Exec and show in scratch buffer | |
" Use # for alternate (last) buffer, since we execute in scratch | |
nnoremap <Leader>r :w<CR>:new<CR>:setlocal buftype=nofile bufhidden=hide noswapfile<CR>:r !./#<CR> | |
" Grep bindings | |
"nnoremap <Leader>gr :grep <cword> *<CR> | |
"nnoremap <Leader>Gr :grep <cword> %:p:h/*<CR> | |
"nnoremap <Leader>gR :grep '\b<cword>\b' *<CR> | |
"nnoremap <Leader>GR :grep '\b<cword>\b' %:p:h/*<CR> | |
" Open NERDTree if no file(s) specified | |
autocmd vimenter * if !argc() | NERDTree | endif | |
" Show hidden files | |
let NERDTreeShowHidden=1 | |
" Disable arrow-keys in insert mode | |
inoremap <up> <nop> | |
inoremap <down> <nop> | |
inoremap <left> <nop> | |
inoremap <right> <nop> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Sets Prezto options. | |
# | |
# Authors: | |
# Sorin Ionescu <[email protected]> | |
# | |
# | |
# General | |
# | |
# Set case-sensitivity for completion, history lookup, etc. | |
# zstyle ':prezto:*:*' case-sensitive 'yes' | |
# Color output (auto set to 'no' on dumb terminals). | |
zstyle ':prezto:*:*' color 'yes' | |
# Set the Zsh modules to load (man zshmodules). | |
# zstyle ':prezto:load' zmodule 'attr' 'stat' | |
# Set the Zsh functions to load (man zshcontrib). | |
# zstyle ':prezto:load' zfunction 'zargs' 'zmv' | |
# Set the Prezto modules to load (browse modules). | |
# The order matters. | |
zstyle ':prezto:load' pmodule \ | |
'environment' \ | |
'terminal' \ | |
'editor' \ | |
'history' \ | |
'directory' \ | |
'spectrum' \ | |
'utility' \ | |
'completion' \ | |
'git' \ | |
'prompt' | |
# | |
# Editor | |
# | |
# Set the key mapping style to 'emacs' or 'vi'. | |
zstyle ':prezto:module:editor' key-bindings 'vi' | |
# Auto convert .... to ../.. | |
zstyle ':prezto:module:editor' dot-expansion 'yes' | |
# | |
# Git | |
# | |
# Ignore submodules when they are 'dirty', 'untracked', 'all', or 'none'. | |
# zstyle ':prezto:module:git:status:ignore' submodules 'all' | |
# | |
# GNU Utility | |
# | |
# Set the command prefix on non-GNU systems. | |
# zstyle ':prezto:module:gnu-utility' prefix 'g' | |
# | |
# History Substring Search | |
# | |
# Set the query found color. | |
# zstyle ':prezto:module:history-substring-search:color' found '' | |
# Set the query not found color. | |
# zstyle ':prezto:module:history-substring-search:color' not-found '' | |
# Set the search globbing flags. | |
# zstyle ':prezto:module:history-substring-search' globbing-flags '' | |
# | |
# Pacman | |
# | |
# Set the Pacman frontend. | |
# zstyle ':prezto:module:pacman' frontend 'yaourt' | |
# | |
# Prompt | |
# | |
# Set the prompt theme to load. | |
# Setting it to 'random' loads a random theme. | |
# Auto set to 'off' on dumb terminals. | |
zstyle ':prezto:module:prompt' theme 'sorin' | |
# | |
# Ruby | |
# | |
# Auto switch the Ruby version on directory change. | |
# zstyle ':prezto:module:ruby:chruby' auto-switch 'yes' | |
# | |
# Screen | |
# | |
# Auto start a session when Zsh is launched in a local terminal. | |
# zstyle ':prezto:module:screen:auto-start' local 'yes' | |
# Auto start a session when Zsh is launched in a SSH connection. | |
# zstyle ':prezto:module:screen:auto-start' remote 'yes' | |
# | |
# SSH | |
# | |
# Set the SSH identities to load into the agent. | |
# zstyle ':prezto:module:ssh:load' identities 'id_rsa' 'id_rsa2' 'id_github' | |
# | |
# Syntax Highlighting | |
# | |
# Set syntax highlighters. | |
# By default, only the main highlighter is enabled. | |
zstyle ':prezto:module:syntax-highlighting' highlighters \ | |
'main' \ | |
'brackets' \ | |
'pattern' \ | |
'cursor' \ | |
'root' | |
# Set syntax highlighting styles. | |
zstyle ':prezto:module:syntax-highlighting' styles \ | |
'builtin' 'bg=blue' \ | |
'command' 'bg=blue' \ | |
'function' 'bg=blue' | |
# | |
# Terminal | |
# | |
# Auto set the tab and window titles. | |
zstyle ':prezto:module:terminal' auto-title 'yes' | |
# Set the window title format. | |
zstyle ':prezto:module:terminal:window-title' format '%n@%m: %s' | |
# Set the tab title format. | |
zstyle ':prezto:module:terminal:tab-title' format '%m: %s' | |
# | |
# Tmux | |
# | |
# Auto start a session when Zsh is launched in a local terminal. | |
# 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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Executes commands at the start of an interactive session. | |
# | |
# Authors: | |
# Sorin Ionescu <[email protected]> | |
# | |
# Source Prezto. | |
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then | |
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" | |
fi | |
# Customize to your needs... | |
## vi mode config | |
export KEYTIMEOUT=1 | |
# Setup undo redo in cmd | |
bindkey -M vicmd '^r' redo | |
bindkey -M vicmd 'u' undo | |
# Make autocomplete cycling work like in vim | |
#bindkey -M menuselect '^P' reverse-menu-complete | |
#bindkey -M menuselect '^N' menu-complete | |
#bindkey -M menuselect 'OA' reverse-menu-complete | |
#bindkey -M menuselect 'OB' menu-complete | |
# Make typing a / to go to the next path component actually finish completion | |
# without inserting another / | |
#bindkey -M menuselect / accept-line | |
# Make G go to the end of history | |
bindkey -M vicmd 'G' end-of-history | |
# Make Y like D and C | |
bindkey -M vicmd 'Y' vi-yank-eol | |
# Expansion of history | |
bindkey ' ' magic-space | |
# Insert literal characters | |
bindkey -M viins '^v' vi-quoted-insert | |
# Same reason as the cc, zsh seems to have problems with the repeats | |
bindkey -M vicmd 'yy' vi-yank-whole-line | |
# Because this sometimes doesn't work as it should with vi-change | |
bindkey -M vicmd 'cc' vi-change-whole-line | |
# History search custom function and bindings | |
autoload -Uz narrow-to-region | |
function _history-incremental-preserving-pattern-search-backward | |
{ | |
local state | |
MARK=CURSOR # magick, else multiple ^R don't work | |
narrow-to-region -p "$LBUFFER${BUFFER:+>>}" -P "${BUFFER:+<<}$RBUFFER" -S state | |
zle end-of-history | |
zle history-incremental-pattern-search-backward | |
narrow-to-region -R state | |
} | |
zle -N _history-incremental-preserving-pattern-search-backward | |
bindkey -M vicmd "/" _history-incremental-preserving-pattern-search-backward | |
bindkey -M vicmd "?" history-incremental-pattern-search-forward | |
bindkey -M viins "^R" _history-incremental-preserving-pattern-search-backward | |
bindkey -M isearch "^R" history-incremental-pattern-search-backward | |
bindkey -M viins "^S" history-incremental-pattern-search-forward | |
# Make forgetful SSH aliases | |
shh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=false" | |
alias -g shsh="ssh $shh_options" | |
alias -g shcp="scp $shh_options" | |
alias -g shftp="sftp $shh_options" | |
alias -g shsync="rsync --rsh 'ssh $shh_options'" | |
unset shh_options | |
# Git aliases | |
alias -g gci="git commit --interactive" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment