Last active 10 months ago

這段腳本檢查並永久將 /usr/local/bin 添加到 PATH,如果尚未存在,則更新 .bashrc,並透過 source ~/.bashrc 立即生效。

timmy revised this gist 10 months ago. Go to revision

No changes

timmy revised this gist 11 months ago. Go to revision

No changes

timmy revised this gist 11 months ago. Go to revision

1 file changed, 11 insertions

add_usr_local_bin_to_path.sh(file created)

@@ -0,0 +1,11 @@
1 + # 永久添加 /usr/local/bin 到 PATH
2 + echo "永久添加 /usr/local/bin 到 PATH..."
3 + if ! grep -q "/usr/local/bin" ~/.bashrc; then
4 + echo 'export PATH=$PATH:/usr/local/bin' >> ~/.bashrc
5 + echo "/usr/local/bin 已添加到 PATH 中。"
6 + else
7 + echo "/usr/local/bin 已在 PATH 中,無需再次添加。"
8 + fi
9 +
10 + # 重新整理環境變數
11 + source ~/.bashrc
Newer Older