Created
May 10, 2017 04:50
-
-
Save aleozlx/4c07d01ec70d69b21026099ed181dfd2 to your computer and use it in GitHub Desktop.
EC2 terminal configs 2015
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
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Maintainer: | |
" Amir Salihefendic | |
" http://amix.dk - amix@amix.dk | |
" | |
" Version: | |
" 5.0 - 29/05/12 15:43:36 | |
" | |
" Blog_post: | |
" http://amix.dk/blog/post/19691#The-ultimate-Vim-configuration-on-Github | |
" | |
" Awesome_version: | |
" Get this config, nice color schemes and lots of plugins! | |
" | |
" Install the awesome version from: | |
" | |
" https://github.com/amix/vimrc | |
" | |
" Syntax_highlighted: | |
" http://amix.dk/vim/vimrc.html | |
" | |
" Raw_version: | |
" http://amix.dk/vim/vimrc.txt | |
" | |
" Sections: | |
" -> General | |
" -> VIM user interface | |
" -> Colors and Fonts | |
" -> Files and backups | |
" -> Text, tab and indent related | |
" -> Visual mode related | |
" -> Moving around, tabs and buffers | |
" -> Status line | |
" -> Editing mappings | |
" -> vimgrep searching and cope displaying | |
" -> Spell checking | |
" -> Misc | |
" -> Helper functions | |
" | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => General | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Sets how many lines of history VIM has to remember | |
set history=700 | |
" Enable filetype plugins | |
filetype plugin on | |
filetype indent on | |
" Set to auto read when a file is changed from the outside | |
set autoread | |
" With a map leader it's possible to do extra key combinations | |
" like <leader>w saves the current file | |
let mapleader = "," | |
let g:mapleader = "," | |
" Fast saving | |
nmap <leader>w :w!<cr> | |
" :W sudo saves the file | |
" (useful for handling the permission-denied error) | |
command W w !sudo tee % > /dev/null | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => VIM user interface | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Set 7 lines to the cursor - when moving vertically using j/k | |
set so=7 | |
" ALX | |
set guifont=Ubuntu\ Mono\ 13 | |
" Turn on the WiLd menu | |
set wildmenu | |
" Ignore compiled files | |
set wildignore=*.o,*~,*.pyc | |
if has("win16") || has("win32") | |
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store | |
else | |
set wildignore+=.git\*,.hg\*,.svn\* | |
endif | |
"Always show current position | |
set ruler | |
" Height of the command bar | |
"set cmdheight=2 | |
" A buffer becomes hidden when it is abandoned | |
set hid | |
" Configure backspace so it acts as it should act | |
set backspace=eol,start,indent | |
set whichwrap+=<,>,h,l | |
" Ignore case when searching | |
set ignorecase | |
" When searching try to be smart about cases | |
set smartcase | |
" Highlight search results | |
set hlsearch | |
" Makes search act like search in modern browsers | |
set incsearch | |
" Don't redraw while executing macros (good performance config) | |
set lazyredraw | |
" For regular expressions turn magic on | |
set magic | |
" Show matching brackets when text indicator is over them | |
set showmatch | |
" How many tenths of a second to blink when matching brackets | |
set mat=2 | |
" No annoying sound on errors | |
set noerrorbells | |
set novisualbell | |
set t_vb= | |
set tm=500 | |
" Add a bit extra margin to the left | |
set foldcolumn=1 | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Colors and Fonts | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Enable syntax highlighting | |
syntax enable | |
try | |
colorscheme desert | |
catch | |
endtry | |
set background=dark | |
" Set extra options when running in GUI mode | |
if has("gui_running") | |
set guioptions-=T | |
set guioptions-=e | |
set t_Co=256 | |
set guitablabel=%M\ %t | |
endif | |
" Set utf8 as standard encoding and en_US as the standard language | |
set encoding=utf8 | |
" Use Unix as the standard file type | |
set ffs=unix,dos,mac | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Files, backups and undo | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Turn backup off, since most stuff is in SVN, git et.c anyway... | |
set nobackup | |
set nowb | |
set noswapfile | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Text, tab and indent related | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Use spaces instead of tabs | |
set expandtab | |
" Be smart when using tabs ;) | |
set smarttab | |
" 1 tab == 4 spaces | |
set shiftwidth=4 | |
set tabstop=4 | |
" Linebreak on 500 characters | |
set lbr | |
set tw=500 | |
set ai "Auto indent | |
set si "Smart indent | |
set wrap "Wrap lines | |
"""""""""""""""""""""""""""""" | |
" => Visual mode related | |
"""""""""""""""""""""""""""""" | |
" Visual mode pressing * or # searches for the current selection | |
" Super useful! From an idea by Michael Naumann | |
vnoremap <silent> * :call VisualSelection('f', '')<CR> | |
vnoremap <silent> # :call VisualSelection('b', '')<CR> | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Moving around, tabs, windows and buffers | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Treat long lines as break lines (useful when moving around in them) | |
map j gj | |
map k gk | |
" Map <Space> to / (search) and Ctrl-<Space> to ? (backwards search) | |
map <space> / | |
map <c-space> ? | |
" Disable highlight when <leader><cr> is pressed | |
map <silent> <leader><cr> :noh<cr> | |
" Smart way to move between windows | |
map <C-j> <C-W>j | |
map <C-k> <C-W>k | |
map <C-h> <C-W>h | |
map <C-l> <C-W>l | |
" Close the current buffer | |
map <leader>bd :Bclose<cr> | |
" Close all the buffers | |
map <leader>ba :1,1000 bd!<cr> | |
" Useful mappings for managing tabs | |
map <leader>tn :tabnew<cr> | |
map <leader>to :tabonly<cr> | |
map <leader>tc :tabclose<cr> | |
map <leader>tm :tabmove | |
map <leader>t<leader> :tabnext | |
" Opens a new tab with the current buffer's path | |
" Super useful when editing files in the same directory | |
map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/ | |
" Switch CWD to the directory of the open buffer | |
map <leader>cd :cd %:p:h<cr>:pwd<cr> | |
" Specify the behavior when switching between buffers | |
try | |
set switchbuf=useopen,usetab,newtab | |
set stal=2 | |
catch | |
endtry | |
" Return to last edit position when opening files (You want this!) | |
autocmd BufReadPost * | |
\ if line("'\"") > 0 && line("'\"") <= line("$") | | |
\ exe "normal! g`\"" | | |
\ endif | |
" Remember info about open buffers on close | |
set viminfo^=% | |
"""""""""""""""""""""""""""""" | |
" => Status line | |
"""""""""""""""""""""""""""""" | |
" Always show the status line | |
set laststatus=2 | |
" Format the status line | |
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Editing mappings | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Remap VIM 0 to first non-blank character | |
map 0 ^ | |
" Move a line of text using ALT+[jk] or Comamnd+[jk] on mac | |
nmap <M-j> mz:m+<cr>`z | |
nmap <M-k> mz:m-2<cr>`z | |
vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z | |
vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z | |
if has("mac") || has("macunix") | |
nmap <D-j> <M-j> | |
nmap <D-k> <M-k> | |
vmap <D-j> <M-j> | |
vmap <D-k> <M-k> | |
endif | |
" Delete trailing white space on save, useful for Python and CoffeeScript ;) | |
func! DeleteTrailingWS() | |
exe "normal mz" | |
%s/\s\+$//ge | |
exe "normal `z" | |
endfunc | |
autocmd BufWrite *.py :call DeleteTrailingWS() | |
autocmd BufWrite *.coffee :call DeleteTrailingWS() | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => vimgrep searching and cope displaying | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" When you press gv you vimgrep after the selected text | |
vnoremap <silent> gv :call VisualSelection('gv', '')<CR> | |
" Open vimgrep and put the cursor in the right position | |
map <leader>g :vimgrep // **/*.<left><left><left><left><left><left><left> | |
" Vimgreps in the current file | |
map <leader><space> :vimgrep // <C-R>%<C-A><right><right><right><right><right><right><right><right><right> | |
" When you press <leader>r you can search and replace the selected text | |
vnoremap <silent> <leader>r :call VisualSelection('replace', '')<CR> | |
" Do :help cope if you are unsure what cope is. It's super useful! | |
" | |
" When you search with vimgrep, display your results in cope by doing: | |
" <leader>cc | |
" | |
" To go to the next search result do: | |
" <leader>n | |
" | |
" To go to the previous search results do: | |
" <leader>p | |
" | |
map <leader>cc :botright cope<cr> | |
map <leader>co ggVGy:tabnew<cr>:set syntax=qf<cr>pgg | |
map <leader>n :cn<cr> | |
map <leader>p :cp<cr> | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Spell checking | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Pressing ,ss will toggle and untoggle spell checking | |
map <leader>ss :setlocal spell!<cr> | |
" Shortcuts using <leader> | |
map <leader>sn ]s | |
map <leader>sp [s | |
map <leader>sa zg | |
map <leader>s? z= | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Misc | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Remove the Windows ^M - when the encodings gets messed up | |
noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm | |
" Quickly open a buffer for scribble | |
map <leader>q :e ~/buffer<cr> | |
" Quickly open a markdown buffer for scribble | |
map <leader>x :e ~/buffer.md<cr> | |
" Toggle paste mode on and off | |
map <leader>pp :setlocal paste!<cr> | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Helper functions | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
function! CmdLine(str) | |
exe "menu Foo.Bar :" . a:str | |
emenu Foo.Bar | |
unmenu Foo | |
endfunction | |
function! VisualSelection(direction, extra_filter) range | |
let l:saved_reg = @" | |
execute "normal! vgvy" | |
let l:pattern = escape(@", '\\/.*$^~[]') | |
let l:pattern = substitute(l:pattern, "\n$", "", "") | |
if a:direction == 'b' | |
execute "normal ?" . l:pattern . "^M" | |
elseif a:direction == 'gv' | |
call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.' . a:extra_filter) | |
elseif a:direction == 'replace' | |
call CmdLine("%s" . '/'. l:pattern . '/') | |
elseif a:direction == 'f' | |
execute "normal /" . l:pattern . "^M" | |
endif | |
let @/ = l:pattern | |
let @" = l:saved_reg | |
endfunction | |
" Returns true if paste mode is enabled | |
function! HasPaste() | |
if &paste | |
return 'PASTE MODE ' | |
en | |
return '' | |
endfunction | |
" Don't close window, when deleting a buffer | |
command! Bclose call <SID>BufcloseCloseIt() | |
function! <SID>BufcloseCloseIt() | |
let l:currentBufNum = bufnr("%") | |
let l:alternateBufNum = bufnr("#") | |
if buflisted(l:alternateBufNum) | |
buffer # | |
else | |
bnext | |
endif | |
if bufnr("%") == l:currentBufNum | |
new | |
endif | |
if buflisted(l:currentBufNum) | |
execute("bdelete! ".l:currentBufNum) | |
endif | |
endfunction |
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
## Lines configured by zsh-newuser-install | |
#HISTFILE=~/.histfile | |
#HISTSIZE=1000 | |
#SAVEHIST=1000 | |
#bindkey -e | |
## End of lines configured by zsh-newuser-install | |
## The following lines were added by compinstall | |
#zstyle :compinstall filename '/home/alex/.zshrc' | |
#autoload -Uz compinit | |
#compinit | |
## End of lines added by compinstall | |
#color{{{ | |
autoload colors | |
colors | |
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]%}" | |
#}}} | |
#命令提示符 | |
#RPROMPT=$(echo "$RED%D %T$FINISH") | |
RPROMPT=$(echo "$RED%T$FINISH") | |
#PROMPT=$(echo "$CYAN%n@$YELLOW%M:$GREEN%/$_YELLOW>$FINISH ") | |
PROMPT=$(echo "$GREEN%M$WHITE:%/ $BLUE%?$FINISH\$ ") | |
# #标题栏、任务栏样式{{{ | |
# case $TERM in (*xterm*|*rxvt*|(dt|k|E)term) | |
# precmd () { print -Pn "\e]0;%n@%M//%/\a" } | |
# preexec () { print -Pn "\e]0;%n@%M//%/\ $1\a" } | |
# ;; | |
# esac | |
# #}}} | |
#编辑器 | |
export EDITOR=vim | |
#输入法 | |
export XMODIFIERS="@im=ibus" | |
export QT_MODULE=ibus | |
export GTK_MODULE=ibus | |
#关于历史纪录的配置 {{{ | |
#历史纪录条目数量 | |
export HISTSIZE=1000 | |
#注销后保存的历史纪录条目数量 | |
export SAVEHIST=1000 | |
#历史纪录文件 | |
export HISTFILE=~/.zhistory | |
#以附加的方式写入历史纪录 | |
setopt INC_APPEND_HISTORY | |
#如果连续输入的命令相同,历史纪录中只保留一个 | |
setopt HIST_IGNORE_DUPS | |
#为历史纪录中的命令添加时间戳 | |
setopt EXTENDED_HISTORY | |
#启用 cd 命令的历史纪录,cd -[TAB]进入历史路径 | |
# setopt AUTO_PUSHD | |
#相同的历史路径只保留一个 | |
# setopt PUSHD_IGNORE_DUPS | |
#在命令前添加空格,不将此命令添加到纪录文件中 | |
#setopt HIST_IGNORE_SPACE | |
#}}} | |
#每个目录使用独立的历史纪录{{{ | |
cd() { | |
builtin cd "$@" # do actual cd | |
fc -W # write current history file | |
local HISTDIR="$HOME/.zsh_history$PWD" # use nested folders for history | |
if [ ! -d "$HISTDIR" ] ; then # create folder if needed | |
mkdir -p "$HISTDIR" | |
fi | |
export HISTFILE="$HISTDIR/zhistory" # set new history file | |
touch $HISTFILE | |
local ohistsize=$HISTSIZE | |
HISTSIZE=0 # Discard previous dir's history | |
HISTSIZE=$ohistsize # Prepare for new dir's history | |
fc -R #read from current histfile | |
} | |
mkdir -p $HOME/.zsh_history$PWD | |
export HISTFILE="$HOME/.zsh_history$PWD/zhistory" | |
function allhistory { cat $(find $HOME/.zsh_history -name zhistory) } | |
function convhistory { | |
sort $1 | uniq | | |
sed 's/^:\([ 0-9]*\):[0-9]*;\(.*\)/\1::::::\2/' | | |
awk -F"::::::" '{ $1=strftime("%Y-%m-%d %T",$1) "|"; print }' | |
} | |
#使用 histall 命令查看全部历史纪录 | |
function histall { convhistory =(allhistory) | | |
sed '/^.\{20\} *cd/i\\' } | |
#使用 hist 查看当前目录历史纪录 | |
function hist { convhistory $HISTFILE } | |
#全部历史纪录 top50 | |
function top50 { allhistory | awk -F':[ 0-9]*:[0-9]*;' '{ $1="" ; print }' | sed 's/ /\n/g' | sed '/^$/d' | sort | uniq -c | sort -nr | head -n 50 } | |
#}}} | |
#杂项 {{{ | |
#允许在交互模式中使用注释 例如: | |
#cmd #这是注释 | |
setopt INTERACTIVE_COMMENTS | |
#启用自动 cd,输入目录名回车进入目录 | |
#稍微有点混乱,不如 cd 补全实用 | |
setopt AUTO_CD | |
#扩展路径 | |
#/v/c/p/p => /var/cache/pacman/pkg | |
setopt complete_in_word | |
#禁用 core dumps | |
limit coredumpsize 0 | |
#Emacs风格 键绑定 | |
bindkey -e | |
#bindkey -v | |
#设置 [DEL]键 为向后删除 | |
#bindkey "\e[3~" delete-char | |
#以下字符视为单词的一部分 | |
WORDCHARS='*?_-[]~=&;!#$%^(){}<>' | |
#}}} | |
#自动补全功能 {{{ | |
setopt AUTO_LIST | |
setopt AUTO_MENU | |
#开启此选项,补全时会直接选中菜单项 | |
#setopt MENU_COMPLETE | |
autoload -U compinit | |
compinit | |
#自动补全缓存 | |
#zstyle ':completion::complete:*' use-cache on | |
#zstyle ':completion::complete:*' cache-path .zcache | |
#zstyle ':completion:*:cd:*' ignore-parents parent pwd | |
#自动补全选项 | |
zstyle ':completion:*' verbose yes | |
zstyle ':completion:*' menu select | |
zstyle ':completion:*:*:default' force-list always | |
zstyle ':completion:*' select-prompt '%SSelect: lines: %L matches: %M [%p]' | |
zstyle ':completion:*:match:*' original only | |
zstyle ':completion::prefix-1:*' completer _complete | |
zstyle ':completion:predict:*' completer _complete | |
zstyle ':completion:incremental:*' completer _complete _correct | |
zstyle ':completion:*' completer _complete _prefix _correct _prefix _match _approximate | |
#路径补全 | |
zstyle ':completion:*' expand 'yes' | |
zstyle ':completion:*' squeeze-shlashes 'yes' | |
zstyle ':completion::complete:*' '\\' | |
#彩色补全菜单 | |
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' | |
#修正大小写 | |
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' | |
#错误校正 | |
zstyle ':completion:*' completer _complete _match _approximate | |
zstyle ':completion:*:match:*' original only | |
zstyle ':completion:*:approximate:*' max-errors 1 numeric | |
#kill 命令补全 | |
compdef pkill=kill | |
compdef pkill=killall | |
zstyle ':completion:*:*:kill:*' menu yes select | |
zstyle ':completion:*:*:*:*:processes' force-list always | |
zstyle ':completion:*:processes' command 'ps -au$USER' | |
#补全类型提示分组 | |
zstyle ':completion:*:matches' group 'yes' | |
zstyle ':completion:*' group-name '' | |
zstyle ':completion:*:options' description 'yes' | |
zstyle ':completion:*:options' auto-description '%d' | |
zstyle ':completion:*:descriptions' format $'\e[01;33m -- %d --\e[0m' | |
zstyle ':completion:*:messages' format $'\e[01;35m -- %d --\e[0m' | |
zstyle ':completion:*:warnings' format $'\e[01;31m -- No Matches Found --\e[0m' | |
zstyle ':completion:*:corrections' format $'\e[01;32m -- %d (errors: %e) --\e[0m' | |
# cd ~ 补全顺序 | |
zstyle ':completion:*:-tilde-:*' group-order 'named-directories' 'path-directories' 'users' 'expand' | |
#}}} | |
##行编辑高亮模式 {{{ | |
# Ctrl+@ 设置标记,标记和光标点之间为 region | |
zle_highlight=(region:bg=magenta #选中区域 | |
special:bold #特殊字符 | |
isearch:underline)#搜索时使用的关键字 | |
#}}} | |
##空行(光标在行首)补全 "cd " {{{ | |
user-complete(){ | |
case $BUFFER in | |
"" ) # 空行填入 "cd " | |
BUFFER="cd " | |
zle end-of-line | |
zle expand-or-complete | |
;; | |
"cd --" ) # "cd --" 替换为 "cd +" | |
BUFFER="cd +" | |
zle end-of-line | |
zle expand-or-complete | |
;; | |
"cd +-" ) # "cd +-" 替换为 "cd -" | |
BUFFER="cd -" | |
zle end-of-line | |
zle expand-or-complete | |
;; | |
* ) | |
zle expand-or-complete | |
;; | |
esac | |
} | |
zle -N user-complete | |
bindkey "\t" user-complete | |
#}}} | |
##在命令前插入 sudo {{{ | |
#定义功能 | |
sudo-command-line() { | |
[[ -z $BUFFER ]] && zle up-history | |
[[ $BUFFER != sudo\ * ]] && BUFFER="sudo $BUFFER" | |
zle end-of-line #光标移动到行末 | |
} | |
zle -N sudo-command-line | |
#定义快捷键为: [Esc] [Esc] | |
bindkey "\e\e" sudo-command-line | |
#}}} | |
#命令别名 {{{ | |
# alias cp='cp -i' | |
# alias mv='mv -i' | |
# alias rm='rm -i' | |
alias ls='ls -F --color=auto' | |
alias ll='ls -l' | |
alias grep='grep --color=auto' | |
alias egrep='egrep --color=auto' | |
alias la='ls -a' | |
# alias pacman='sudo pacman-color' | |
# alias p='sudo pacman-color' | |
# alias y='yaourt' | |
# alias h='htop' | |
# alias kill='kill -9' | |
# alias vim='sudo vim' | |
#[Esc][h] man 当前命令时,显示简短说明 | |
alias run-help >&/dev/null && unalias run-help | |
autoload run-help | |
#历史命令 top10 | |
alias top10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10' | |
#}}} | |
#路径别名 {{{ | |
#进入相应的路径时只要 cd ~xxx | |
hash -d A="/media/ayu/dearest" | |
hash -d H="/media/data/backup/ayu" | |
hash -d E="/etc/" | |
hash -d D="/home/ayumi/Documents" | |
#}}} | |
##for Emacs {{{ | |
#在 Emacs终端 中使用 Zsh 的一些设置 不推荐在 Emacs 中使用它 | |
#if [[ "$TERM" == "dumb" ]]; then | |
#setopt No_zle | |
#PROMPT='%n@%M %/ | |
#>>' | |
#alias ls='ls -F' | |
#fi | |
#}}} | |
#{{{自定义补全 | |
#补全 ping | |
zstyle ':completion:*:ping:*' hosts 192.168.1.{1,50,51,100,101} www.google.com | |
#补全 ssh scp sftp 等 | |
#zstyle -e ':completion::*:*:*:hosts' hosts 'reply=(${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) /dev/null)"}%%[# ]*}//,/ })' | |
#}}} | |
#{{{ F1 计算器 | |
arith-eval-echo() { | |
LBUFFER="${LBUFFER}echo \$(( " | |
RBUFFER=" ))$RBUFFER" | |
} | |
zle -N arith-eval-echo | |
bindkey "^[[11~" arith-eval-echo | |
#}}} | |
####{{{ | |
function timeconv { date -d @$1 +"%Y-%m-%d %T" } | |
# }}} | |
zmodload zsh/mathfunc | |
autoload -U zsh-mime-setup | |
zsh-mime-setup | |
setopt EXTENDED_GLOB | |
#autoload -U promptinit | |
#promptinit | |
#prompt redhat | |
setopt correctall | |
autoload compinstall | |
#漂亮又实用的命令高亮界面 | |
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 | |
# The next line updates PATH for the Google Cloud SDK. | |
source '/home/ubuntu/google-cloud-sdk/path.zsh.inc' | |
# The next line enables shell command completion for gcloud. | |
source '/home/ubuntu/google-cloud-sdk/completion.zsh.inc' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment