Skip to content

Instantly share code, notes, and snippets.

@trzecieu
Last active November 4, 2016 18:47
Show Gist options
  • Save trzecieu/db8847ddc34e97e35705739c50b62338 to your computer and use it in GitHub Desktop.
Save trzecieu/db8847ddc34e97e35705739c50b62338 to your computer and use it in GitHub Desktop.
@rem File is based on CmdInit.cmd from ConEmu folder
@rem To make it work, it's required to change tasks in XML
@echo off
:: I would like to achieve efect like:
:: User@PC PATH
:: Where @ becomes # if admin
rem Simple "ver" prints empty line before Windows version
rem Use this construction to print just a version info
cmd /d /c ver | "%windir%\system32\find.exe" "Windows"
rem This will start prompt with `User@PC `
set ConEmuPrompt0=$E[m$E[32m$E]9;8;"USERNAME"$E
:: If running as admin, then $
if "%ConEmuIsAdmin%" == "ADMIN" (
set ConEmuPrompt0=%ConEmuPrompt0%\$
) else (
set ConEmuPrompt0=%ConEmuPrompt0%\@
)
set ConEmuPrompt0=%ConEmuPrompt0%$E]9;8;"COMPUTERNAME"$E\$S
rem Followed by colored `Path`
set ConEmuPrompt1=%ConEmuPrompt0%$E[92m$P$E[90m
if NOT "%PROCESSOR_ARCHITECTURE%" == "AMD64" (
if "%PROCESSOR_ARCHITEW6432%" == "AMD64" if "%PROCESSOR_ARCHITECTURE%" == "x86" (
rem Use another text color if cmd was run from SysWow64
set ConEmuPrompt1=%ConEmuPrompt0%$E[93m$P$E[90m
)
)
rem Finally reset color and add space
set ConEmuPrompt3=$E[m$S$E]9;12$E\
PROMPT %ConEmuPrompt1%%ConEmuPrompt3%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment