Sometimes I have Git Bash open for several days, and knowing when I executed a particular command is helpful. Here's a quick-and-dirty way of showing the date and time in the bash prompt, which came about from looking at C:\Program Files\Git\etc\profile.d\git-prompt.sh
and doing echo $PS1
.
- Copy the following content into a text editor and save it as
.profile
in the%USERPROFILE%
folder:
PS1="\[\033]0;$TITLEPREFIX:$PWD\007\]\n\[\033[94m\]\D{%m/%d %H:%M:%S} \[\033[32m\]\u@\h \[\033[35m\]$MSYSTEM \[\033[33m\]\w\[\033[36m\]"'`__git_ps1`'"\[\033[0m\]\n$ " MSYS2_PS1="$PS1"
- Run
source .profile
to reload the prompt.
For the full list of configurable colors, refer to ANSI Color Escape Codes.
So how did I know to create the .profile
file? There's a .bash_profile
file in the %USERPROFILE%
folder:
# generated by Git for Windows test -f ~/.profile && . ~/.profile test -f ~/.bashrc && . ~/.bashrc
Windows Terminal
Lately, I've been trying out Windows Terminal with oh-my-posh for PowerShell (based on the post by Scott Hanselman). You can also host cmd
, bash
(via wsl), etc., in Windows Terminal... I fear my days of using plain cmd
and Git Bash on Windows will come to an end soon, though I'll surely miss the start up time of cmd
.
No comments:
Post a Comment