Tuesday, November 28, 2017

Iterm2+zsh+oh my zsh+Solarized+auto completion

zsh+on my zsh+iterm2
http://wdxtub.com/2016/02/18/oh-my-zsh/

git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k

OSX插件:
pfd:显示finder当前路径
cdf:进入finder当前路径

Auto-completion 1
http://yijiebuyi.com/blog/36955b84c57e338dd8255070b80829bf.html

Auto-completion 2
https://github.com/zsh-users/zsh-autosuggestions

Solarized 配色
http://www.jianshu.com/p/e45160d0ae27

ls 高亮
https://github.com/gibbling/dircolors

vim插件管理
http://blog.csdn.net/zhangpower1993/article/details/52184581

nerd 插件
http://www.jianshu.com/p/eXMxGx

.vimrc配置
set nocompatible              " be iMproved, required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

" let Vundle manage Bundles, required
Plugin 'VundleVim/Vundle.vim'

" plugin on GitHub repo, but not vim-scripts' repo
Plugin 'tpope/vim-fugitive'
Plugin 'Lokaltog/vim-powerline'
Plugin 'Valloric/YouCompleteMe'
Plugin 'scrooloose/nerdtree'
Plugin 'scrooloose/nerdcommenter'
Plugin 'kien/ctrlp.vim'
Plugin 'jelera/vim-javascript-syntax'
Plugin 'othree/html5.vim'
Plugin 'klen/python-mode'
Plugin 'vim-ruby/vim-ruby'
Plugin 'tpope/vim-rails'
Plugin 'jiangmiao/auto-pairs'

" plugin from http://vim-scripts.org/vim/scripts.html
" Git plugin not hosted on GitHub
"Plugin 'git://git.wincent.com/command-t.git'

" git repos on your local machine (i.e. when working on your own plugin)
"Plugin 'file:///home/gmarik/path/to/plugin'

" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
"Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}

" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.

" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList       - lists configured plugins
" :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line

let mapleader=','
set clipboard=unnamed
set mouse=a "启用鼠标
set nobackup
set nowritebackup
set noswapfile
set hlsearch "高亮搜索结果
set incsearch "搜索时一边输入一边显示效果
set tabstop=4
set shiftwidth=4
set t_Co=256
set backspace=2 "可随时用倒退键删除
set autoindent "自动缩进
set cindent "针对C语言的自动缩进
set smartindent "智能缩进
set ruler "可显示最后一列的状态
set cursorline "突出显示当前行
set showmatch "插入括号时,短暂地跳转到匹配的对应括号
set showmode "左下角那一列的状态
set showcmd  "display incomplete commands
set nowrapscan "禁止在搜索到文件两端时重新搜索
set ic "搜索时忽略大小写
set foldenable "开始折叠
set foldmethod=syntax "设置语法折叠
set foldcolumn=0 "设置折叠区域的宽度
setlocal foldlevel=1 "设置折叠层数为
nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR> " 用空格键来开关折叠
set laststatus=2 "显示状态栏 (默认值为 1, 无法显示状态栏)
set nu "可以在每一列的最前面显示行号
set bg=dark "显示不同的底色色调
syntax on "进行语法检验,颜色显示
syntax enable
colorscheme solarized
" Nerd Tree
let NERDChristmasTree=0
let NERDTreeWinSize=40
let NERDTreeChDirMode=2
let NERDTreeIgnore=['\~$', '\.pyc$', '\.swp$']
let NERDTreeShowBookmarks=1
let NERDTreeWinPos="left"
autocmd vimenter * if !argc() | NERDTree | endif " Automatically open a NERDTree if no files where specified
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif " Close vim if the only window left open is a NERDTree
nmap <F5> :NERDTreeToggle<cr>

" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1
" Use compact syntax for prettified multi-line comments
let g:NERDCompactSexyComs = 1
" Align line-wise comment delimiters flush left instead of following code indentation
let g:NERDDefaultAlign = 'left'
" Set a language to use its alternate delimiters by default
let g:NERDAltDelims_java = 1
" Allow commenting and inverting empty lines (useful when commenting a region)
let g:NERDCommentEmptyLines = 1
" Enable trimming of trailing whitespace when uncommenting
let g:NERDTrimTrailingWhitespace = 1




# ZSH的环境变量
export ZSH=/Users/songjiang/.oh-my-zsh
# 主题设置
# 主题列表在 ~/.oh-my-zsh/themes/
# 如果设置为 "random", 每次开启都会是不同的主题
ZSH_THEME="agnoster"
# 如果想要大小写敏感,可以取消注释下面的一行
# CASE_SENSITIVE="true"
# 如果想要连接符不敏感,可以取消注释下面的一行。_ 和 - 将可以互换
# HYPHEN_INSENSITIVE="true"
# 如果不想要自动更新,可以取消注释下面的一行
# DISABLE_AUTO_UPDATE="true"
# 自动更新的时间间隔,单位是天,这里设置 30 天更新一次
export UPDATE_ZSH_DAYS=60
# 如果不想要 ls 命令输出带颜色,可以取消注释下面的一行
# DISABLE_LS_COLORS="true"
# 是否禁止更改终端标题,不要禁止,不然所有终端tab只显示zsh了,而不随着目录的改变而改变显示
# DISABLE_AUTO_TITLE="true"
# 自动纠正命令,不启用,不怎么好用
# ENABLE_CORRECTION="true"
# 按tab键补全命令的时候,如果没什么可补全的就会出现三个红点,更人性化显示,这里我们启用
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"
# 历史命令日期显示格式
# 有三种方式: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd",我比较习惯最后那种
HIST_STAMPS="yyyy-mm-dd"
# 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)
# 插件设置,如果添加太多启动速度会比较慢
plugins=(git autojump osx)
[[ -s ~/.autojump/etc/profile.d/autojump.zsh ]] && . ~/.autojump/etc/profile.d/autojump.zsh
# 剩下部分比较不常改动
# User configuration
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/TeX/texbin"
# export MANPATH="/usr/local/man:$MANPATH"
source $ZSH/oh-my-zsh.sh
# 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/dsa_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"
alias ls='gls --color=auto'
alias ll='ls -al'
alias grep='grep --color'
alias egrep='egrep --color'
alias fgrep='fgrep --color'

#terminal变成256色
export TERM=xterm-256color
#语法高亮
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
#自动补全1(高级,但复制到terminal很慢)
#source ~/.oh-my-zsh/plugins/incr/incr*.zsh
#自动补全2(中级)
source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh
#ls高亮
eval $(gdircolors ~/.dircolors/dircolors.256dark)

#export PYTHONPATH=/usr/local/lib/python3.6/site-packages:$PYTHONPATH
#
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home
export JAVA_HOME
export PATH=$JAVA_HOME/bin:$PATH



VIMRC:

Vimrc


source /apollo/env/envImprovement/var/vimrc

set nocompatible              " be iMproved, required

filetype off                  " required



" set the runtime path to include Vundle and initialize

set rtp+=~/.vim/bundle/Vundle.vim

call vundle#begin()

" let Vundle manage Bundles, required

Plugin 'VundleVim/Vundle.vim'


" plugin on GitHub repo, but not vim-scripts' repo

Plugin 'tpope/vim-fugitive'

Plugin 'Lokaltog/vim-powerline'

Plugin 'Valloric/YouCompleteMe'

Plugin 'scrooloose/nerdtree'

Plugin 'scrooloose/nerdcommenter'

Plugin 'kien/ctrlp.vim'

Plugin 'jelera/vim-javascript-syntax'

Plugin 'othree/html5.vim'

Plugin 'klen/python-mode'

Plugin 'vim-ruby/vim-ruby'

Plugin 'tpope/vim-rails'

Plugin 'jiangmiao/auto-pairs'



" plugin from http://vim-scripts.org/vim/scripts.html

" Git plugin not hosted on GitHub

"Plugin 'git://git.wincent.com/command-t.git'



" git repos on your local machine (i.e. when working on your own plugin)

"Plugin 'file:///home/gmarik/path/to/plugin'



" The sparkup vim script is in a subdirectory of this repo called vim.

" Pass the path to set the runtimepath properly.

"Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}



" Install L9 and avoid a Naming conflict if you've already installed a

" different version somewhere else.



" All of your Plugins must be added before the following line

call vundle#end()            " required

filetype plugin indent on    " required

" To ignore plugin indent changes, instead use:

"filetype plugin on

"

" Brief help

" :PluginList       - lists configured plugins

" :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate

" :PluginSearch foo - searches for foo; append `!` to refresh local cache

" :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal

"

" see :h vundle for more details or wiki for FAQ

" Put your non-Plugin stuff after this line
"

let mapleader=','

set clipboard=unnamed

set mouse=a "启用鼠标

set nobackup

set nowritebackup

set noswapfile

set hlsearch "高亮搜索结果

set incsearch "搜索时一边输入一边显示效果

set tabstop=4

set shiftwidth=4

set t_Co=256

set backspace=2 "可随时用倒退键删除

set autoindent "自动缩进

set cindent "针对C语言的自动缩进

set smartindent "智能缩进

set ruler "可显示最后一列的状态

set cursorline "突出显示当前行

set showmatch "插入括号时,短暂地跳转到匹配的对应括号

set showmode "左下角那一列的状态

set showcmd  "display incomplete commands

set nowrapscan "禁止在搜索到文件两端时重新搜索

set ic "搜索时忽略大小写

set foldmethod=syntax "设置语法折叠

set foldcolumn=0 "设置折叠区域的宽度

setlocal foldlevel=1 "设置折叠层数为

nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR> " 用空格键来开关折叠

set laststatus=2 "显示状态栏 (默认值为 1, 无法显示状态栏)

set nu "可以在每一列的最前面显示行号

set bg=dark "显示不同的底色色调

syntax on "进行语法检验,颜色显示

syntax enable




ZSHRC:

Zshrc


export BRAZIL_WORKSPACE_DEFAULT_LAYOUT=short

for f in SDETools envImprovement AmazonAwsCli OdinTools; do
    if [[ -d /apollo/env/$f ]]; then
        export PATH=$PATH:/apollo/env/$f/bin
    fi
done

export AUTO_TITLE_SCREENS="NO"

export PROMPT="
%{$fg[white]%}(%D %*) <%?> [%~] $program %{$fg[default]%}
%{$fg[cyan]%}%m %#%{$fg[default]%} "

export RPROMPT=

set-title() {
    echo -e "\e]0;$*\007"
}

ssh() {
    set-title $*;
    /usr/bin/ssh -2 $*;
    set-title $HOST;
}

alias timberIAD='sshenv TimberFS/IAD/DeeOpsTimber' #NA Gamma, NA Prod, EU Alpha, EU Beta
alias timberDUB='sshenv TimberFS/DUB/DeeOpsTimber' #EU Gamma, EU Prod
alias timberPDX='sshenv TimberFS/PDX/DeeOpsTimber' #FE Gamma, FE Prod, NA Alpha, NA Beta

if [ -f ~/.zshrc-dev-dsk-post ]; then
    source ~/.zshrc-dev-dsk-post
fi

PATH="/usr/NX/bin:/usr/local/bin:/bin:/usr/bin:/home/sonjiang/bin:/usr/local/sbin:/usr/sbin:/sbin:/apollo/env/envImprovement/bin:/apollo/env/AmazonAwsCli/bin:/apollo/env/OdinTools/bin"

alias vim='/apollo/env/envImprovement/bin/vim'

alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias e=emacs
alias bb=brazil-build
alias bbs='bb server'
alias bws='brazil ws'
alias dryrun='brazil ws --dryrun'
alias e=emacs
alias bb=brazil-build
alias bbs='bb server'
alias bws='brazil ws'
alias dryrun='brazil ws --dryrun'
alias bshow='brazil ws show'
alias bsync='brazil ws sync -md'
alias bclean='bws clean'
alias brmws='brazil ws --delete --root'
alias brmpkg='brazil ws --remove -p'
alias bcache='brazil-package-cache clean'
alias bvs='brazil ws --use --versionset'
alias bre='brazil-runtime-exec'
alias ninja='ninja-dev-sync'
alias ninjasetup='ninja -setup'

alias gs='git status'
alias gcm='git commit -m'
alias gb='git branch'
alias gc='git checkout'
alias gcb='git checkout -b'
alias gst='git stash'
alias gstp='git stash pop'
alias gl='git log'
alias gd='git diff'
alias gpr='git pull --rebase'
alias ga='git add .'
alias gcall='ga && git commit -a --amend --no-edit'

alias deact='sudo /apollo/bin/runCommand -a Deactivate -e '
alias act='sudo /apollo/bin/runCommand -a Activate -e '
alias assssAAA='sudo /apollo/bin/runCommand -a Activate -e AlexaSkillSearchSpeechletService.CONSUMES.AAASecurityDaemon'

alias ut='python3 -m http.server'

alias bigfile='sudo find / -xdev -type f -size +100000000c -print'

alias aaa="/apollo/env/AAAWorkspaceSupport/bin/register_with_aaa.py -a"

source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh

[[ -s /home/sonjiang/.autojump/etc/profile.d/autojump.sh ]] && source /home/sonjiang/.autojump/etc/profile.d/autojump.sh

autoload -U compinit && compinit -u

export PATH=$HOME/.toolbox/bin:$PATH
export PATH=/apollo/env/SDETools/bin:$PATH


Monday, November 27, 2017

Linux

du -sh 文件或目录名称:列出文件或目录的总容量
du -ah 文件或目录名称:列出所有的文件与目录容量

df -h: 列出系统内所有的filesystem


Wednesday, November 22, 2017

Git

版本回退:
git log: 查看提交历史
git log --graph: 查看分支合并图
git reflog: 查看命令历史
git reset --hard commit_id: 回退到了某个版本
git reset --hard HEAD^: 回退到上一个版本
git reset --hard HEAD~10: 回退到之前第十个版本

撤销修改:
git checkout -- file: 可以丢弃工作区的修改(或删除操作), 让file这个文件回到最近一次git commit或git add时的状态
git reset HEAD file: 可以把暂存区的修改撤销掉,重新放回工作区

分支管理:
git merge --no-ff -m <commit-info> <branch-name>: 强制禁用Fast forward模式,Git就会在merge时生成一个新的commit,从分支历史上就可以看出分支信息
git stash: 把当前工作现场“储存”起来
git stash apply: 恢复储存的内容,但是恢复后,stash内容并不删除
git stash drop: 删除stash的内容
git stash pop: 恢复的同时把stash内容也删了
git stash apply stash@{0}: 如果有多次stash的话,选择恢复某个stash内容

配置别名:
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

实际工作:
git checkout mainline
git pull
git checkout dev
git rebase mainline
(resolve conflicts + commit)
git checkout mainline
git merge dev
git push origin mainline