
我注意到我的 MSYS bash 不「知道」我的系統上定義的環境變數。這意味著,如果該資料夾C:\MyStuff\bin\
位於我的路徑中,並且該資料夾包含mycommand.exe
,那麼mycommand
在 MSYS 終端中運行將返回錯誤,指示找不到該資料夾。
如何將 MSYS 與系統的其餘部分乾淨地「整合」?這是應該避免的事情嗎?
答案1
如何將 MSYS 與系統的其餘部分乾淨地「整合」?
我使用(與其工作方式Cygwin
類似)並選擇性地將部分 Windows 路徑新增至我的 bash 路徑,如下所示:msys
我有一個檔案 ( .path_elements
),其中包含我想要在 bash 路徑中出現的目錄:
/home/DavidPostill/bin:
/usr/local/bin:
/usr/bin:
/c/Windows/system32:
/c/Windows
注意:如果您在文件中新增行,則.path_elements
它們必須以以下字元終止:
(最後一行除外)。
我修改了我的.bash.profile
文件如下:
#DCP 20151019 comment out the original code for setting PATH
# Set PATH so it includes user's private bin if it exists
# if [ -d "${HOME}/bin" ] ; then
# PATH="${HOME}/bin:${PATH}"
# fi
#DCP 20151019
# Build up the path using the directories in ~/.path_elements
unset PATH
while read line; do
PATH="${PATH}$line";
done < ~/.path_elements
…
#DCP 20151019
# Add current directory to path
export PATH=".:${PATH}"
現在在我的bash
外殼中:
$ echo $PATH
.:/home/DavidPostill/bin:/usr/local/bin:/usr/bin:/c/Windows/system32:/c/Windows
$
您應該能夠在 中做一些非常類似的事情msys
。