Last active
January 9, 2018 07:04
-
-
Save ttop5/bb21f160925ded28b5520d71de60ac5e to your computer and use it in GitHub Desktop.
macos profiles
This file contains hidden or 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
" leader | |
let mapleader = ',' | |
let g:mapleader = ',' | |
" syntax | |
syntax on | |
" history : how many lines of history VIM has to remember | |
set history=2000 | |
" filetype | |
filetype on | |
" Enable filetype plugins | |
filetype plugin on | |
filetype indent on | |
" base | |
set nocompatible " don't bother with vi compatibility | |
set autoread " reload files when changed on disk, i.e. via `git checkout` | |
set shortmess=atI | |
set magic " For regular expressions turn magic on | |
set title " change the terminal's title | |
set nobackup " do not keep a backup file | |
set novisualbell " turn off visual bell | |
set noerrorbells " don't beep | |
set visualbell t_vb= " turn off error beep/flash | |
set t_vb= | |
set tm=500 | |
" show location | |
set cursorcolumn | |
set cursorline | |
" movement | |
set scrolloff=7 " keep 3 lines when scrolling | |
" show | |
set ruler " show the current row and column | |
set number " show line numbers | |
set nowrap | |
set showcmd " display incomplete commands | |
set showmode " display current modes | |
set showmatch " jump to matches when entering parentheses | |
set matchtime=2 " tenths of a second to show the matching parenthesis | |
" search | |
set hlsearch " highlight searches | |
set incsearch " do incremental searching, search as you type | |
set ignorecase " ignore case when searching | |
set smartcase " no ignorecase if Uppercase char present | |
" tab | |
set expandtab " expand tabs to spaces | |
set smarttab | |
set shiftround | |
" indent | |
set autoindent smartindent shiftround | |
set shiftwidth=4 | |
set tabstop=4 | |
set softtabstop=4 " insert mode tab and backspace use 4 spaces | |
" NOT SUPPORT | |
" fold | |
set foldenable | |
set foldmethod=indent | |
set foldlevel=99 | |
let g:FoldMethod = 0 | |
map <leader>zz :call ToggleFold()<cr> | |
fun! ToggleFold() | |
if g:FoldMethod == 0 | |
exe "normal! zM" | |
let g:FoldMethod = 1 | |
else | |
exe "normal! zR" | |
let g:FoldMethod = 0 | |
endif | |
endfun | |
" encoding | |
set encoding=utf-8 | |
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1 | |
set termencoding=utf-8 | |
set ffs=unix,dos,mac | |
set formatoptions+=m | |
set formatoptions+=B | |
" select & complete | |
set selection=inclusive | |
set selectmode=mouse,key | |
set completeopt=longest,menu | |
set wildmenu " show a navigable menu for tab completion" | |
set wildmode=longest,list,full | |
set wildignore=*.o,*~,*.pyc,*.class | |
" others | |
set backspace=indent,eol,start " make that backspace key work the way it should | |
set whichwrap+=<,>,h,l | |
" if this not work ,make sure .viminfo is writable for you | |
if has("autocmd") | |
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif | |
endif | |
" NOT SUPPORT | |
" Enable basic mouse behavior such as resizing buffers. | |
" set mouse=a | |
" ============================ theme and status line ============================ | |
" theme | |
set background=dark | |
colorscheme desert | |
" set mark column color | |
hi! link SignColumn LineNr | |
hi! link ShowMarksHLl DiffAdd | |
hi! link ShowMarksHLu DiffChange | |
" status line | |
set statusline=%<%f\ %h%m%r%=%k[%{(&fenc==\"\")?&enc:&fenc}%{(&bomb?\",BOM\":\"\")}]\ %-14.(%l,%c%V%)\ %P | |
set laststatus=2 " Always show the status line - use 2 lines for the status bar | |
" ============================ specific file type =========================== | |
autocmd FileType python set tabstop=4 shiftwidth=4 expandtab ai | |
autocmd FileType ruby set tabstop=2 shiftwidth=2 softtabstop=2 expandtab ai | |
autocmd BufRead,BufNew *.md,*.mkd,*.markdown set filetype=markdown.mkd | |
autocmd BufNewFile *.sh,*.py exec ":call AutoSetFileHead()" | |
function! AutoSetFileHead() | |
" .sh | |
if &filetype == 'sh' | |
call setline(1, "\#!/bin/bash") | |
endif | |
" python | |
if &filetype == 'python' | |
call setline(1, "\#!/usr/bin/env python") | |
call append(1, "\# encoding: utf-8") | |
endif | |
normal G | |
normal o | |
normal o | |
endfunc | |
autocmd FileType c,cpp,java,go,php,javascript,puppet,python,rust,twig,xml,yml,perl autocmd BufWritePre <buffer> :call <SID>StripTrailingWhitespaces() | |
fun! <SID>StripTrailingWhitespaces() | |
let l = line(".") | |
let c = col(".") | |
%s/\s\+$//e | |
call cursor(l, c) | |
endfun | |
" ============================ key map ============================ | |
nnoremap k gk | |
nnoremap gk k | |
nnoremap j gj | |
nnoremap gj j | |
map <C-j> <C-W>j | |
map <C-k> <C-W>k | |
map <C-h> <C-W>h | |
map <C-l> <C-W>l | |
nnoremap <F2> :set nu! nu?<CR> | |
nnoremap <F3> :set list! list?<CR> | |
nnoremap <F4> :set wrap! wrap?<CR> | |
set pastetoggle=<F5> " when in insert mode, press <F5> to go to | |
" paste mode, where you can paste mass data | |
" that won't be autoindented | |
au InsertLeave * set nopaste | |
nnoremap <F6> :exec exists('syntax_on') ? 'syn off' : 'syn on'<CR> | |
" kj 替换 Esc | |
inoremap kj <Esc> | |
" Quickly close the current window | |
nnoremap <leader>q :q<CR> | |
" Quickly save the current file | |
nnoremap <leader>w :w<CR> | |
" select all | |
map <Leader>sa ggVG" | |
" remap U to <C-r> for easier redo | |
nnoremap U <C-r> | |
" Swap implementations of ` and ' jump to markers | |
" By default, ' jumps to the marked line, ` jumps to the marked line and | |
" column, so swap them | |
nnoremap ' ` | |
nnoremap ` ' | |
" switch # * | |
" nnoremap # * | |
" nnoremap * # | |
"Keep search pattern at the center of the screen." | |
nnoremap <silent> n nzz | |
nnoremap <silent> N Nzz | |
nnoremap <silent> * *zz | |
nnoremap <silent> # #zz | |
nnoremap <silent> g* g*zz | |
" remove highlight | |
noremap <silent><leader>/ :nohls<CR> | |
"Reselect visual block after indent/outdent.调整缩进后自动选中,方便再次操作 | |
vnoremap < <gv | |
vnoremap > >gv | |
" y$ -> Y Make Y behave like other capitals | |
map Y y$ | |
"Map ; to : and save a million keystrokes | |
" ex mode commands made easy 用于快速进入命令行 | |
nnoremap ; : | |
" save | |
cmap w!! w !sudo tee >/dev/null % | |
" command mode, ctrl-a to head, ctrl-e to tail | |
cnoremap <C-j> <t_kd> | |
cnoremap <C-k> <t_ku> | |
cnoremap <C-a> <Home> | |
cnoremap <C-e> <End> |
This file contains hidden or 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
# If you come from bash you might have to change your $PATH. | |
# export PATH=$HOME/bin:/usr/local/bin:$PATH | |
# Path to your oh-my-zsh installation. | |
export ZSH=/Users/ttop5/.oh-my-zsh | |
# Set name of the theme to load. Optionally, if you set this to "random" | |
# it'll load a random theme each time that oh-my-zsh is loaded. | |
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes | |
ZSH_THEME="robbyrussell" | |
# Set list of themes to load | |
# Setting this variable when ZSH_THEME=random | |
# cause zsh load theme from this variable instead of | |
# looking in ~/.oh-my-zsh/themes/ | |
# An empty array have no effect | |
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" ) | |
# Uncomment the following line to use case-sensitive completion. | |
# CASE_SENSITIVE="true" | |
# Uncomment the following line to use hyphen-insensitive completion. Case | |
# sensitive completion must be off. _ and - will be interchangeable. | |
# HYPHEN_INSENSITIVE="true" | |
# Uncomment the following line to disable bi-weekly auto-update checks. | |
# DISABLE_AUTO_UPDATE="true" | |
# Uncomment the following line to change how often to auto-update (in days). | |
# export UPDATE_ZSH_DAYS=13 | |
# Uncomment the following line to disable colors in ls. | |
# DISABLE_LS_COLORS="true" | |
# Uncomment the following line to disable auto-setting terminal title. | |
# DISABLE_AUTO_TITLE="true" | |
# Uncomment the following line to enable command auto-correction. | |
# ENABLE_CORRECTION="true" | |
# Uncomment the following line to display red dots whilst waiting for completion. | |
# COMPLETION_WAITING_DOTS="true" | |
# Uncomment the following line if you want to disable marking untracked files | |
# under VCS as dirty. This makes repository status check for large repositories | |
# much, much faster. | |
# DISABLE_UNTRACKED_FILES_DIRTY="true" | |
# Uncomment the following line if you want to change the command execution time | |
# stamp shown in the history command output. | |
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" | |
# HIST_STAMPS="mm/dd/yyyy" | |
# Would you like to use another custom folder than $ZSH/custom? | |
# ZSH_CUSTOM=/path/to/new-custom-folder | |
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) | |
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ | |
# Example format: plugins=(rails git textmate ruby lighthouse) | |
# Add wisely, as too many plugins slow down shell startup. | |
plugins=( | |
git | |
) | |
source $ZSH/oh-my-zsh.sh | |
# User configuration | |
# export MANPATH="/usr/local/man:$MANPATH" | |
# You may need to manually set your language environment | |
# export LANG=en_US.UTF-8 | |
# Preferred editor for local and remote sessions | |
# if [[ -n $SSH_CONNECTION ]]; then | |
# export EDITOR='vim' | |
# else | |
# export EDITOR='mvim' | |
# fi | |
# Compilation flags | |
# export ARCHFLAGS="-arch x86_64" | |
# ssh | |
# export SSH_KEY_PATH="~/.ssh/rsa_id" | |
# Set personal aliases, overriding those provided by oh-my-zsh libs, | |
# plugins, and themes. Aliases can be placed here, though oh-my-zsh | |
# users are encouraged to define aliases within the ZSH_CUSTOM folder. | |
# For a full list of active aliases, run `alias`. | |
# | |
# Example aliases | |
# alias zshconfig="mate ~/.zshrc" | |
# alias ohmyzsh="mate ~/.oh-my-zsh" | |
#命令高亮部分 | |
#color{{{ | |
autoload colors zsh/terminfo | |
if [[ "$terminfo[colors]" -ge 8 ]]; then | |
colors | |
fi | |
for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do | |
eval _$color='%{$terminfo[bold]$fg[${(L)color}]%}' | |
eval $color='%{$fg[${(L)color}]%}' | |
(( count = $count + 1 )) | |
done | |
FINISH="%{$terminfo[sgr0]%}" | |
#}}} | |
#彩色补全菜单 | |
# eval $(dircolors -b) | |
export ZLSCOLORS="${LS_COLORS}" | |
zmodload zsh/complist | |
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} | |
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31' | |
##行编辑高亮模式 {{{ | |
# Ctrl+@ 设置标记,标记和光标点之间为 region | |
zle_highlight=(region:bg=magenta #选中区域 | |
special:bold #特殊字符 | |
isearch:underline)#搜索时使用的关键字 | |
#}}} | |
#命令别名 {{{ | |
alias -g ll='ls -la' | |
alias -g cp='cp -i' | |
alias -g mv='mv -i' | |
alias -g grep='grep --color=auto' | |
alias -g ee='emacsclient -t' | |
#漂亮又实用的命令高亮界面 | |
setopt extended_glob | |
TOKENS_FOLLOWED_BY_COMMANDS=('|' '||' ';' '&' '&&' 'sudo' 'do' 'time' 'strace') | |
recolor-cmd() { | |
region_highlight=() | |
colorize=true | |
start_pos=0 | |
for arg in ${(z)BUFFER}; do | |
((start_pos+=${#BUFFER[$start_pos+1,-1]}-${#${BUFFER[$start_pos+1,-1]## #}})) | |
((end_pos=$start_pos+${#arg})) | |
if $colorize; then | |
colorize=false | |
res=$(LC_ALL=C builtin type $arg 2>/dev/null) | |
case $res in | |
*'reserved word'*) style="fg=magenta,bold";; | |
*'alias for'*) style="fg=cyan,bold";; | |
*'shell builtin'*) style="fg=yellow,bold";; | |
*'shell function'*) style='fg=green,bold';; | |
*"$arg is"*) | |
[[ $arg = 'sudo' ]] && style="fg=red,bold" || style="fg=blue,bold";; | |
*) style='none,bold';; | |
esac | |
region_highlight+=("$start_pos $end_pos $style") | |
fi | |
[[ ${${TOKENS_FOLLOWED_BY_COMMANDS[(r)${arg//|/\|}]}:+yes} = 'yes' ]] && colorize=true | |
start_pos=$end_pos | |
done | |
} | |
check-cmd-self-insert() { zle .self-insert && recolor-cmd } | |
check-cmd-backward-delete-char() { zle .backward-delete-char && recolor-cmd } | |
zle -N self-insert check-cmd-self-insert | |
zle -N backward-delete-char check-cmd-backward-delete-char | |
export NVM_DIR="$HOME/.nvm" | |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm | |
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion | |
[[ -s $(brew --prefix)/etc/profile.d/autojump.sh ]] && . $(brew --prefix)/etc/profile.d/autojump.sh # autojump |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment