标签:
1、安装cheat
[root@bogon ~]# yum -y install python
[root@bogon ~]# yum -y install wget
- [root@bogon ~]# wget https://bootstrap.pypa.io/get-pip.py
- [root@bogon ~]# python get-pip.py
[root@bogon ~]# yum -y install git
[root@bogon ~]# pip install docopt pygments
[root@bogon ~]# git clone https://github.com/chrisallenlane/cheat
[root@bogon ~]# cd cheat/
[root@bogon cheat]# python setup.py install
[root@bogon cheat]# cheat -v
cheat 2.1.26
# cheat -e foo
[root@localhost ~]# cheat -d
/root/.cheat
/usr/lib/python2.6/site-packages/cheat/cheatsheets #cheat默认的常用命令保存路径
[root@localhost ~]# mkdir /opt/cheats
[root@localhost ~]# vim ~/.bashrc #设置参数(见参数)
[root@localhost ~]# source ~/.bashrc #使设置生效
[root@localhost ~]# cheat -d
/opt/cheat #默认cheat保存路径已经改变
/usr/lib/python2.6/site-packages/cheat/cheatsheets
export DEFAULT_CHEAT_DIR=‘/opt/cheat‘ #设置cheat默认保存路径
export EDITOR=/usr/bin/vim #设置默认编辑器(可根据自己喜好添加,如nano等)
export CHEATCOLORS=true #语法高亮
[root@localhost ~]# wget https://github.com/chrisallenlane/cheat/raw/master/cheat/autocompletion/cheat.bash
[root@localhost ~]# mv cheat.bash /etc/bash_completion.d/
[root@localhost ~]# cat /etc/bash_completion.d/cheat.bash
function _cheat_autocomplete {
sheets=$(cheat -l | cut -d‘ ‘ -f1)
COMPREPLY=()
if [ $COMP_CWORD = 1 ]; then
COMPREPLY=(`compgen -W "$sheets" -- $2`)
fi
}
complete -F _cheat_autocomplete cheat
[root@localhost ~]# cat /etc/bash_completion.d/cheat.fish
#completion for cheat
complete -c cheat -s h -l help -f -x --description "Display help and exit"
complete -c cheat -l edit -f -x --description "Edit <cheatsheet>"
complete -c cheat -s e -f -x --description "Edit <cheatsheet>"
complete -c cheat -s l -l list -f -x --description "List all available cheatsheets"
complete -c cheat -s d -l cheat-directories -f -x --description "List all current cheat dirs"
complete -c cheat --authoritative -f
for cheatsheet in (cheat -l | cut -d‘ ‘ -f1)
complete -c cheat -a "$cheatsheet"
complete -c cheat -o e -a "$cheatsheet"
complete -c cheat -o ‘-edit‘ -a "$cheatsheet"
end
[root@localhost ~]# cat /etc/bash_completion.d/cheat.zsh
#compdef cheat
#
#declare -a cheats
#cheats=$(cheat -l | cut -d‘ ‘ -f1)
#_arguments "1:cheats:(${cheats})" && return 0
[root@localhost ~]#
标签:
原文地址:http://www.cnblogs.com/chinas/p/5744086.html