iT邦幫忙

0

cmd 是否有像linux bash shell的PS1環境變數能設定?

  • 分享至 

  • xImage

主要是想在cmd每一行指令最前面顯示某個變數,例如一般CMD進去是這樣
C:\Users>
想要加個變數在最前面 假設a=測試模式 %a%C:\Users> 實際上會顯示

測試模式C:\Users>

且不管輸入甚麼指令,測試模式那行字都可以一直出現在前面。

查到linux的bash shell可以用PS1='測試模式'$PWD 達到想要的結果。

想請問有沒有人知道CMD有沒有類似的環境變數能設定?

或著是別的方法能達成也可以,感謝。

看更多先前的討論...收起先前的討論...
slime iT邦大師 1 級 ‧ 2019-05-08 16:54:35 檢舉
prompt 測試$p$g
vit5015 iT邦新手 3 級 ‧ 2019-05-08 17:59:45 檢舉
感謝,一句話解決我的困擾,找了很久沒找到關鍵字,真的感謝你。
PROMPT /? gives you:

$A & (Ampersand)
$B | (pipe)
$C ( (Left parenthesis)
$D Current date
$E Escape code (ASCII code 27)
$F ) (Right parenthesis)
$G > (greater-than sign)
$H Backspace (erases previous character)
$L < (less-than sign)
$N Current drive
$P Current drive and path
$Q = (equal sign)
$S (space)
$T Current time
$V Windows XP version number
$_ Carriage return and linefeed
$$ $ (dollar sign)
$+ zero or more plus sign (+) characters depending upon the
depth of the PUSHD directory stack, one character for each
level pushed.
$M Displays the remote name associated with the current drive
letter or the empty string if current drive is not a network
drive.
vit5015 iT邦新手 3 級 ‧ 2019-05-09 13:13:11 檢舉
感謝熱心幫助。
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答