Advertisement
T3RRYT3RR0R

Advanced Custom colored prompt

Sep 13th, 2020 (edited)
496
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.86 KB | None | 0 0
  1. @ECHO Off & Goto :main
  2. +------------------------------------------------------------------------------------------------+
  3. :ColorString
  4.     (For %%C in (%~1)Do Set "rv=!rV!%/E%[!#A!m%%~C"& Set /A "#A+=1"& IF "!#A!"=="37" (Set #A=31))
  5. Exit /B 0
  6. +------------------------------------------------------------------------------------------------+
  7. :main
  8.  For /F %%a in ('echo prompt $E ^| cmd')do (Set "/E=%%a")
  9.  Set "Off=%/E%[0m" &Set "#A=31"
  10.  Set "ColLETTERS=Set "Rv="& Set "#A=31" & (For %%A in ("$V")Do Set "Word=!%%~A!" & For %%B In (0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z . - _ [ ] / \ ":")Do Set "Word=!Word:%%~B=%%~B !") & (Call :ColorString "!Word!" & Set "#$V#=!rV!")"
  11.  Set "ColWORDS=Set "#$V#=!$V!"&For %%G in ("!$V:\=;!")Do (For %%v in (%%~G)Do (Set "Rv=" & Call :Colorstring "%%~v" &For %%x in (!Rv!)Do (Set "#$V#=!#$V#:\%%~v=%Off%\%%~x!")))"
  12.  Setlocal EnableDelayedExpansion
  13.  %ColWORDS:$V=CD%
  14.  %ColLETTERS:$V=ComputerName%
  15. rem // colored strings from the above two macro's are returned in %#VARNAME#%
  16. rem // Prompt macro will fail in an environment where delayed expansion is enabled.
  17. rem // Alternate prompt ::: Endlocal & Set "C_Prompt=Prompt %/E%[36m%Username% %/E%[37mOn: %#ComputerName#%%/E%[37m In: %/E%[36m%#CD#%%/E%[90m $$%/E%[36m^> %/E%[33m"
  18.  Endlocal & Set "C_Prompt=Prompt %#CD#%%/E%[90m $$%/E%[36m^> %/E%[33m"
  19.  %C_Prompt%
  20. Goto :Eof
  21.  
  22.  
  23. For random Color changes, replace the contents of the colorstring function with the below routine
  24.  
  25. +------------------------------------------------------------------------------------------------+
  26.  (For %%C in (%~1)Do Set /A "R=!Random! %% 255 + 40,G=!Random! %% 205 + 40,B=!Random! %% 205 + 40" & Set "rv=!rV!%/E%[38;2;!R!;!G!;!B!m%%~C"& Set /A "#A+=1"& IF "!#A!"=="37" (Set #A=31))
  27. Exit /B 0
  28. +------------------------------------------------------------------------------------------------+
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement