linux 修改shell提示

2021-06-23 08:40:07 字數 623 閱讀 5403

操作只針對使用bash的普通使用者.

1.普通變數:示例: export ps1="$"

回車後效果就出來了.

或者:export ps1="> "

bash即bourne shee都會將提示的值存在叫乙個叫:ps1的環境變數中.export修改環境變數的值.

注意點,"="前後不能有空格.

2.引用變數

使用行中輸入:name='csdn' ;export ps1="$"

可以省略"大括號"

同樣可以引用系統的變數如:

export  ps1="$hostname"

3. 特殊變數

這些變數只能在提示中使用。

"\w 工作目錄,~表示法" "\w 工作目錄"\w和\w的區別,\w會顯示全路徑,從使用者的根目錄開始。如:在目錄books下里,\w顯示:~/desktop/books

\w顯示:books

"."完整路徑名

"\h"計算機的主機名

"\u"當前使用者標識,即使用者名稱

"\s"shell的名稱

"\@"時間,am/pm表示法

"\a"時間,24小時制表示

"\d"日期

不同的shll的特殊變數不一範圍不同。

Linux修改Shell命令提示符及顏色

etc profile etc profile.d sh bash profile bashrc etc bashrc 可檢視預設的 bashrc檔案如下 root cat bashrc bashrc user specific aliases and functions source global...

Linux修改Shell命令提示符及顏色

1.linux登入過程中載入配置檔案順序 etc profile etc profile.d sh bash profile bashrc etc bashrc 可檢視預設的 bashrc檔案如下 fi2.shell命令提示符及顏色是由ps1來配置 root etc init.d echo ps1 ...

Linux修改Shell命令提示符及顏色

1.linux登入過程中載入配置檔案順序 etc profile etc profile.d sh bash profile bashrc etc bashrc 可檢視預設的 bashrc檔案如下 1 root localhost cat bashrc 2 bashrc34 user specifi...