终端命令太长解决方法+设置环境变量

终端命令太长解决方法:

比如:phpunit命令

问题,用pear正常安装phpunit后,没法在终端直接使用。

方法一:使用alias(别名)
文档:http://doc.linuxpk.com/5966.html

格式:alias zm='cd /home/name/Desktop/' #注意,这里是单引号

在liangzhongyuan的目录下面,有个.bash_profile 的shell(bash)配置文件。

实例:alias phpunit='pear/bin/phpunit'

方法二:设置环境变量
文档:http://www.cnblogs.com/elfsundae/archive/2010/12/01/1893190.html
http://blog.csdn.net/larntin2002/article/details/1946600

实例:export PATH="/Users/liangzhongyuan/pear/bin:$PATH"


上面两种方法,经测试,实用,哈哈哈,,

以后就可以直接用phpunit命令,bash不会报什么not found command。

备注phpunit在yii下有个特性:phpunit unit/MCCustomerTest.php

只有上面这条命令才能运行,如果phpunit Sites/OrderManage/protected/tests/unit/MCCustomerTest.php 就会报错,说

Class 'CTestCase' not found in /Users/liangzhongyuan/Sites/OrderManage/protected/tests/unit/MCCustomerTest.php on line 8

1、以专家为榜样,不必自己重新探索
2、解构技能,找出实现80%效果的那20%
3、不要一心二用
4、练习练习再练习!然后获得即时反馈
5、坚持,不要在低谷期放弃
原文地址:https://www.cnblogs.com/zhongyuan/p/3024570.html