Ⅰ. 插件描述
Context-sensitive alias for ZshⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'uasi/zsh-context-sensitive-alias'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'uasi/zsh-context-sensitive-alias'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'uasi/zsh-context-sensitive-alias'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/uasi/zsh-context-sensitive-alias
Ⅳ. 文档说明
# Context-Sensitive Alias for Zsh
特定のコンテキストで有効になるエイリアスを定義できるスクリプトです。
使い方:
# {{{ in ~/.zshrc
# 初期化
source csa.zsh
csa_init
# コンテキストを指定してエイリアスを定義する
# csalias <context> <alias> <command>
csalias git st 'git status'
csalias hg st 'hg status'
csalias rake ra 'rake'
csalias bundler ra 'bundle exec rake'
# cd 先のリポジトリの種類に合わせてコンテキストを設定する(詳細は sample-zshrc.zsh で)
function chpwd() { ... }
# }}}
# Git リポジトリに cd すると st == git status になる
$ cd git-repo
$ st
# On branch master
nothing to commit (working directory clean)
# Hg リポジトリに cd すると st == hg status になる
$ cd hg-repo
$ st
? readme.txt
# リポジトリでないディレクトリでは st は未定義
$ cd not-a-repo
$ st
zsh: command not found: st
# Rakefile があるディレクトリに cd すると ra == rake になる
$ cd some-ruby-lib
$ ra --version
rake, version 9.2.2
# Gemfile があるディレクトリに cd すると ra == bundle exec rake になる
# (同じディレクトリに Rakefile があっても ra == rake にはならない)
$ cd some-rails-proj
$ ra --version
rake, version 9.1.0設定方法については sample-zshrc.zsh をご覧ください。