English 中文(简体)
如何缩短Gite Bash Prompt(Windows)
原标题:How to Shorten Git Bash Prompt (Windows)

我如何从像这样的东西中缩短我的血汗。

Malik@LAPTOP-7R9912OI MINGW64 ~/Desktop/test
$

......

Malik@test$

I am using git bash on windows with git version 2.21.0 (26-02-2019)

最佳回答

在Gite Bash:

cd ~
notepad .bashrc

在说明中,添加以下条目:PS1=“foobar>”; (replace foobar>, with any text You Hope)

在Gite Bash节省~/.bashrc后,指挥:

source ~/.bashrc
问题回答

另一种答案是进入<代码>C:Program filesGitetcprofile.d,开放git-prompt.sh。 报告载有Gite Bash的缺席配置/准备。

if test -f /etc/profile.d/git-sdk.sh
then
    TITLEPREFIX=SDK-${MSYSTEM#MINGW}
else
    TITLEPREFIX=$MSYSTEM
fi

if test -f ~/.config/git/git-prompt.sh
then
    . ~/.config/git/git-prompt.sh
else
    PS1= [33]0;$TITLEPREFIX:$PWD07]  # set window title
    PS1="$PS1" 
                  # new line
    PS1="$PS1" [33[32m]        # change to green
    # PS1="$PS1" u@h               # user@host<space>
    # PS1="$PS1" [33[35m]        # change to purple
    # PS1="$PS1" $MSYSTEM            # show MSYSTEM
    # PS1="$PS1" [33[33m]        # change to brownish yellow
    PS1="$PS1" W                  # current working directory
    if test -z "$WINELOADERNOEXEC"
    then
        GIT_EXEC_PATH="$(git --exec-path 2>/dev/null)"
        COMPLETION_PATH="${GIT_EXEC_PATH%/libexec/git-core}"
        COMPLETION_PATH="${COMPLETION_PATH%/lib/git-core}"
        COMPLETION_PATH="$COMPLETION_PATH/share/git/completion"
        if test -f "$COMPLETION_PATH/git-prompt.sh"
        then
            . "$COMPLETION_PATH/git-completion.bash"
            . "$COMPLETION_PATH/git-prompt.sh"
            PS1="$PS1" [33[36m]   # change color to cyan
            PS1="$PS1" `__git_ps1`    # bash function
        fi
    fi
    PS1="$PS1" [33[0m]         # change color
    # PS1="$PS1" 
                  # new line
    PS1="$PS1"  $                   # prompt: always $
fi

MSYS2_PS1="$PS1"               # for detection by MSYS2 SDK s bash.basrc

# Evaluate all user-specific Bash completion scripts (if any)
if test -z "$WINELOADERNOEXEC"
then
    for c in "$HOME"/bash_completion.d/*.bash
    do
        # Handle absence of any scripts (or the folder) gracefully
        test ! -f "$c" ||
        . "$c"
    done
fi

在我的组合中,我对<代码>user@host<space>,MINGW64/code>作了评论,并通过将<代码>w改为/code>将工作目录改为其基准名称。

Yes, just reset PS1 environment variable in .bashrc file.
Like this:

export PS1= [33[32m]u@[33[35m]$MSYSTEM [33[33m]w[33[36m]`__git_ps1`[33[0m]
$ 

I tried opening Vim text editor in Windows bash and revised the prompt as I have on my Mac.  I could not get the notepad to work as cleanly as using Vim.  I did not want to make any unnecessary config changes.  This method seems straight forward and missing from this thread so I thought I would include what worked for me to change my Bash prompt.

First I opened bashrc file with Vim text editor.

Second I clicked on the letter I on the keyboard to insert text in Vim.

Third I input the desired prompt.

Fourth I wrote (saved) and quit Vim.

Lastly reference the source file of my prompt change.

$ vim .bashrc

In Vim
 - i for Insert
 - PS1="foobar> "
 - Shift + w + q to save command in Vim

To enforce the settings in BASH
$ source ~/.bashrc





相关问题
Why running a service as Local System is bad on windows?

I am trying to find out the difference between difference service account types. I tumbled upon this question. The answer was because it has powerful access to local resources, and Network Service ...

Programmatically detect Windows cluster configuration?

Does anyone know how to programatically detect that a Windows server is part of a cluster? Further, is it possible to detect that the server is the active or passive node? [Edit] And detect it from ...

get file icon for Outlook appointment (.msg)

I ve read Get File Icon used by Shell and the other similar posts - and already use SHFileInfo to get the associated icon for any given extension, and that works great. However, Outlook uses ".msg" ...

Identifying idle state on a windows machine

I know about the GetLastInputInfo method but that would only give me the duration since last user input - keyboard or mouse. If a user input was last received 10 minutes ago, that wouldn t mean the ...

Terminating a thread gracefully not using TerminateThread()

My application creates a thread and that runs in the background all the time. I can only terminate the thread manually, not from within the thread callback function. At the moment I am using ...

热门标签