.profile.d 分散式的 profile 設定檔管理 - Linux

Table of Contents

# .profile.d #
# 分散式的 profile 設定檔管理專案 #
<https://github.com/Lin-Buo-Ren/.profile.d>

.profile 為類 Unix 作業系統中使用者登入後會一次性載入並執行的設定檔,主要用來
設定使用者的環境變數(包含作為可執行檔搜索路徑的 `PATH` 環境變數)。

本專案是用來放置原本使用者會放置於`〈家目錄〉/.profile` 個人設定檔的腳本片段,
這樣就可以最小程度地讓使用者自訂的 .profile 片段汙染 GNU/Linux 作業系統散佈版
本提供的版本且讓該片段可以被重複利用。

您需要在家目錄中新建 .profile.d 目錄(如果該目錄原本還沒存在的話),然後將您的
profile 個人設定檔片段以 .source.sh 副檔名寫進 .profile.d 目錄中,.profile 中
的程式會自動引入(source)並執行。

## 特色 / Features ##
* 備有將指定目錄插入 shell 可執行檔搜尋路徑(`PATH` 環境變數)中的工具函式
* 如果指定目錄不存在或是 `PATH` 中已有相同路徑將不會添加,避免增加搜尋路徑的多
餘時間

## 設定 / Setup ##
1. 將本版控庫拓製(clone)或下載解開到家目錄中的 .profile.d 目錄,確定
`README.setup` 與其他檔案位於 ~/.profile.d 目錄中
2. 在 ~/.profile 設定檔中加入下列內容:

# Setup .profile.d/
# https://github.com/Lin-Buo-Ren/.profile.d
. "${HOME}/.profile.d/README.setup"

您需要重新登出再登入才能讓設定生效

## 注意 / Remark ##
.profile 為通用的 script 程式,應使用 [POSIX.1-2008 規範的 shell script 語法
](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html )而
非 Bash 等殼層程式的專有語法撰寫

## 授權條款 / License ##
GPLv3+

--

All Comments

Liam avatarLiam2017-04-23
source 裡面放中文路徑?
Cara avatarCara2017-04-25
純補個血
Cara avatarCara2017-04-29
複製貼上一不小心就u8←→b5轉碼了 還是盡量避免啦
Blanche avatarBlanche2017-04-29
其實不同 shell 基本上設定檔案不大一樣
centos 來說用 bash, bash 是有機會讀取 .profile
Bennie avatarBennie2017-05-03
但是那也是 .bash_profile 找不到這類才有機會使用到
Elma avatarElma2017-05-07
幫補
Kelly avatarKelly2017-05-09
一般 centos 的 .bash_profile 主要是讀入 .bashrc
source .profile 必要性?其實我感覺主要是使用者
要瞭解 shell 程式讀取檔案的項目,貿然套 .profile
Quanna avatarQuanna2017-05-11
不一定也正確。有人用 csh 這類不就破工了? 檔名不同
Erin avatarErin2017-05-13
簡單說這篇文章陳述的內容考量部分比較少就是
Quintina avatarQuintina2017-05-17
George avatarGeorge2017-05-22
原帖樓主可以裝一下redhat或是centos瞭解它的設定檔案
設定規劃流程
Regina avatarRegina2017-05-25
整體來說個人覺得您這一篇整個幫助性不高
Liam avatarLiam2017-05-28
其實你只需要提供簡單幾行 for 迴圈敘述就好了
Queena avatarQueena2017-05-30
說明提供的一些腳本達能目的用途就好了
Caitlin avatarCaitlin2017-06-04
釣老人也很好用 XD
Gilbert avatarGilbert2017-06-05
老人大多有自己一套方式
Delia avatarDelia2017-06-06
Life finds a way...
Ursula avatarUrsula2017-06-10
其實直接改 PATH 比較直觀,包成函數反而要想一下
Kristin avatarKristin2017-06-12
shell scripting 本來就是每個人用自已的
除非要寫 pyenv 這種工具,不用追求相容性
Todd Johnson avatarTodd Johnson2017-06-17
如果直接用environment modules?