首先進入bin文件夾,新建一個文件enbuild
$ cd ~/bin
$ touch enbuild
賦予這個文件可執行權限
$ chmod u+x enbuild
編輯這個文件
$ vim enbuild
寫一個簡單的sh腳本並保存:
#!/bin/sh
#get the path of current folder
Cur_Dir=$(pwd)
if [ "$Cur_Dir" = "/home/ywx/code/ep820" ] ;then
echo "you are in ep820 folder! Start to build environment for ep820"
source /home/ywx/code/ep820/build/envsetup.sh
choosecombo 1 EP820 3 1 1 1
else
echo "you are in nowhere!"
fi
然後,進入到項目文件下,執行 . enbuild,如果是正確的項目路徑,就會執行編譯環境的設置。
如果有新的項目,增加新的條件分支即可。
有個問題,此時用 .來執行腳本無法按tab鍵自動補全,不是很方便,希望能找到解決辦法。