linux||mac os如何自定義shell命令

李博Garvin發表於2015-03-06

     博主是goagent忠實使用者,但是在mac下每次啟動goagent都要cd到proxy的目錄下,然後再執行proxy.py檔案,非常麻煩,所以博主想到能否自己定義一個shell命令,一健啟動goagent,其實也很簡單,過程如下。


(1)我們在user目錄下輸入,"-a"是現實隱藏的檔案
ls -a

(2)展現出了很多前邊是"."的檔案,這種檔案在通常情況下是隱藏的
hirotekiMacBook-Pro:~ hakuri$ ls -a
.
..
.CFUserTextEncoding
.DS_Store
.Rapp.history
.Trash
.android
.bash_history
.bash_profile
.bash_profile.macports-saved_2014-09-30_at_09:53:49
.bash_profile.pysave
.bash_profile”.save
.bash_profile”.save.1
.bashrc

(3)開啟.bash_profile檔案,這個檔案是每次當前使用者啟動中端都需要啟動的配置檔案(我習慣用sublime改程式碼,大家也可以用vim等自己習慣的)
(4)這裡用到了“alias”指令,就是別名的意思,給一個名令取一個別名。多個命令間可以用“&&”隔開,把這句話加到.bash_profile檔案裡。例子如下:
alias fuckgfw='cd /Applications/goagent/local && python proxy.py'
  

下面驗證下: 
 




/********************************

* 本文來自部落格  “李博Garvin“

* 轉載請標明出處:http://blog.csdn.net/buptgshengod

******************************************/





相關文章