new plugin:better alias

This commit is contained in:
CodeFalling 2014-08-23 19:13:11 +08:00
parent fdf3793b60
commit 691a9a2bc9
3 changed files with 28 additions and 0 deletions

View File

@ -2,6 +2,7 @@
* __android-sdk__ – [Android SDK](http://developer.android.com/sdk/index.html) integration.
* __archlinux__ – Provides a number of plugins to make using Arch Linux easier.
* __autojump__ – Makes navigating filesystem much faster. See [autojump article](https://github.com/joelthelion/autojump/wiki) and [video](https://www.youtube.com/watch?v=tnNyoMGnbKg). Bindings only, autojump needs to be installed separately.
* __better-alias__ - Provide alias with auto completion.
* __brew__ – [Homebrew](http://brew.sh/) integration.
* __bundler__ – Use Ruby's [Bundler](http://bundler.io/) automatically for some commands.
* __ccache__ – Enable [ccache](http://ccache.samba.org/) to speed up compilation.

View File

@ -0,0 +1,16 @@
# A better alias provide completion
Use `balias` instead of `alias`,you can get same completion meanwhile you set alias.
# Example
```
balias apti 'sudo apt-get install'
balias gc 'git checkout'
```
Then,you will get
![apti](http://www.geekpics.net/images/2014/08/23/TJn6kfBY.png)
![gc](http://www.geekpics.net/images/2014/08/23/655x76xcPJolvxqra.png.pagespeed.ic.4S9hgPfZ53.png)

View File

@ -0,0 +1,11 @@
function balias --argument alias command
eval 'alias $alias $command'
if expr match $command '^sudo '>/dev/null
set command (expr substr + $command 6 (expr length $command))
end
complete -c $alias -xa "(
set -l cmd (commandline -pc | sed -e 's/^ *\S\+ *//' );
complete -C\"$command \$cmd\";
)"
end