Open HoLengZai opened 3 years ago
My workaround for this issue is to use __posh_git_echo
function instead of __posh_git_ps1
in $PROMPT_COMMAND
and manually removing the previous git information using sed, based on a delimiter character I added to my $PS1
previously (here >
):
function prompt_command {
PS1="$(echo $PS1 | sed 's/>.*/>/') $(__posh_git_echo)\n$ "
}
PROMPT_COMMAND=prompt_command;$PROMPT_COMMAND
My PS1 is defined like this (notice the >
at the end):
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w> '
Another advantage of this technique is that it keeps your previous PS1 customizations (if any) but keep in mind that it will break if the delimiter character appears before in the PS1, for instance in the path. It should not appear too often if you carefully choose your delimiter.
There are also some other neat suggestions in this SO question that may help. Virtualenv modifies the shell prompt, so some elbow grease is required to make sure only at most one tool modifies PROMPT_COMMAND
.
Been a while, but this tool is still very nice. I have come up with a workaround for this problem. Just use an additional function in the RC to 'enhance' the prompt. Use the following:
getBaseDir () {
base_dir=""
if [[ -n "$VIRTUAL_ENV" ]]; then
base_dir+="("
base_dir+=$(basename $VIRTUAL_ENV)
base_dir+=")"
fi
echo $base_dir
}
PROMPT_COMMAND='__posh_git_ps1 "$(getBaseDir)\[\033[01;32m\] ➞ \[\033[00m\]" "" "" " ";'$PROMPT_COMMAND
My prompt only consists of an arrow. In order to additionally display the ENV call getBaseDir
in the first set of quotes and everything should be fine.
Hi,
When you activate a Python virtualenv, posh-git-sh got the priority and I don't see the name of my virtual env on the prompt. It is a bit annoying because I don't know if I am in my virtualenv or not.
I don't have this issue using the original powershell post-git version
I should get something like that:
I got this instead