Opengist

Explore

  • All gists
  • Topics
  • Users
Give feedback on the new UI Powered by Opengist ⋅ 639ms

user:thomas gists created by user

title:mygist gists with given title

description:sync gists with given description

filename:myfile.txt gists having files with given name

extension:yml gists having files with given extension

language:go gists having files with given language

topic:homelab gists with given topic

all:systemctl search all fields

Login
p

path

Recently created Least recently created Recently updated Least recently updated

timmy / 永久添加 /usr/local/bin 到 PATH

Last active 5 hours ago automation bash environment linux path script shell

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

1 0 0 1
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 # 重新整理環境變數