Coder Social home page Coder Social logo

posh-git-sh's People

Contributors

allykzam avatar dewe avatar elderry avatar erikhuizinga avatar hashhar avatar ibayramli avatar jkrot avatar jlucktay avatar lyze avatar metronnie avatar moosekaka avatar mrsheepuk avatar pfeif-master avatar rdnlsmith avatar reneschumacher avatar stuffaboutpete avatar tirolo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

posh-git-sh's Issues

output='' error information will show in shell prompt

Hi, I got an error when using this script.

please take a look at it.

alexya@Alex-MacPro [08:52:19] [~/Source/Git/posh-git-sh] output=''
[output_error_info ?]
-> $ ls
README.md git-prompt.sh

after investigating, I think it may happen in git-prompt.sh

    # Find how many commits we are ahead/behind our upstream
    if [ -z "$legacy" ]; then
        local output
        output=$(git rev-list --count --left-right $upstream...HEAD 2>/dev/null)
        return_code=$?
        IFS=$' \t\n' read -r __POSH_BRANCH_BEHIND_BY __POSH_BRANCH_AHEAD_BY <<< $output
    else
        local output
        output=$(git rev-list --left-right $upstream...HEAD 2>/dev/null)
        return_code=$?
        # produce equivalent output to --count for older versions of git
        while IFS=$' \t\n' read -r commit; do
            case "$commit" in
            "<*") (( __POSH_BRANCH_BEHIND_BY++ )) ;;
            ">*") (( __POSH_BRANCH_AHEAD_BY++ ))  ;;
            esac
        done <<< $output
    fi

the line local output will print error information output='' in shell. (I don't know the reason)
The fix is to change to

        local output=$(git rev-list --count --left-right $upstream...HEAD 2>/dev/null)

and then, the shell is good. e.g.

alexya@Alex-MacPro [08:56:56] [~/Source/Git/posh-git-sh] [output_error_info ≡]
-> $ ls
README.md git-prompt.sh

I don't have the permission to create a branch, so, could u please take a look at it?

My macos version is 10.10.1
git version is 2.7.2
shell is oh-my-zsh

npm install puts incorrect function name in .bashrc

I couldn't find a place to open an issue on the npm site, so I'm opening one here.

When I install posh-git-sh on my mac using npm ("sudo npm install -g posh-git" followed by "posh-git-install" for local user), the installation puts in the following lines:

source ~/posh-git.sh
PROMPT_COMMAND='__git_ps1 "\u@\h: \w" "\$ ":'$PROMPT_COMMAND

And I get the following error:
-bash: __git_ps1: command not found

The issue is that posh-git.sh does NOT have a function by that name. Instead, it is called __posh_git_ps1(){...}. I've updated my .bashrc to call the right function, but it would be nice if it is corrected in the npm install.

Thanks,

Yasir

conda environment suffix is lost

Using conda, when an environment different to root is used, the name of the environment is prepended in the system command:
(environment-name) user@linux ~ $
This behavior is lost when using posh-git-sh is in use.
Regardless the active conda environment, the command always prompt looks this way:
user@linux ~ $
The Git Status information still displayed correctly

Stash status symbol

Currently the symbol used to show if there's anything in stash is a '$' - that's also the default ending character for most default prompt setups. As a result there's a doubled '$' character when there's something in stash.
It would be great to change that to something else (a '*' maybe?) and even better to have this parametrized.

Bash 5 warning: ignored null byte in input

I have a Bash warning popping up, but only when my working directory is inside a git repo that is checked out to a specific version tag:

bash: warning: command substitution: ignored null byte in input

To reproduce, it would go something like this in an empty directory:

git init
echo "hello world" > foo.txt
git add .
git commit --message "foo bar"
git tag v1.2.3
git checkout v1.2.3

After that, every time you press Enter and get a new prompt, the warning will show.

The warning shows up even with an extremely basic prompt configured, such as: PROMPT_COMMAND='__posh_git_ps1 "hello " "\nworld \\$ "'

I have $BASH_VERSION 5.0.11(1)-release and git is 2.24.0

__git_ps1 already defined

I had a problem where __git_ps1 would always output (branche_name), even though I included your file. This is fixed if I change the name of __git_ps1 to something like __git_ps1_new.
I don't know how or where, but something was rewriting the function call.

(now that I got it working it's a lovely piece of work, you deserve more recognition for this!)

Weird characters on Bash on Ubuntu on Windows

First of all, @lyze, huge thank you for porting this extension to bash! I've been using Powershell with Git on Windows for the better part of my career. Now I'm transitioning to Hyper with native Bash on Windows in Windows 10 - and I'm happy that I can continue using this excellent syntax.

I followed your instructions precisely:
bashrc

And consequently the prompt is shown with the Git Posh syntax, on Hyper:
hypertm
However, do you notice the in the start of the prompt line?

My goal is to use Hyper (terminal emulator) with the native Bash on Windows (which is Bash version 4.3). However, if I'm just loading Bash by itself, this is what I'm getting:
bash on windows

As you can see the repo status is all messed up, but I don't mind because it displays correctly on Hyper. But can you see that character in the start of the prompt line?

Strange $17 at the end of the prompt

Thank you very much for porting this extension to bash.
I just tried to install it yesterday and everything is working fine, except that I have a strange $17 at the end of my prompt when it's using git-prompt

nicolas@X260-NICOLAS:~ 
$ cd Source/java/slipdb/
nicolas@X260-NICOLAS:~/Source/java/slipdb [feat/filter-object ≡]$17
$ rm src/ -r
nicolas@X260-NICOLAS:~/Source/java/slipdb [feat/filter-object ≡ +0 ~0 -106]$17
$ git reset --hard 
HEAD is now at 39b76c6 implement our filter object idea
nicolas@X260-NICOLAS:~/Source/java/slipdb [feat/filter-object ≡]$17
$ 

Command prompt configuration:

PROMPT_COMMAND='__posh_git_ps1 "\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\] " "\n\$ ";'$PROMPT_COMMAND

simple instructions for zsh

As all of you know, now macbook comes with zsh, not bash.
But the instructions are not so clear for zsh.
I had to install Homebrew first, which took some time, but it was pretty good. (I had to enter computer password a few times)

  1. But the under "Install Bash git completion", something had to be added to ".bash_profile" but I don't think it will work for zsh.
  2. Then I am supposed to enter "source ~/git-prompt.sh" to .bash_profile, but I don't think zsh reads this either. So I put that into .zshrc, and it seems working, but not sure if this is safe or not.

So, I guess, it would be just nice to write a section for those who uses zsh, not bash.

ZSH

Hello.
How can I add git status in .zshrc?

Hide status symbol when no upstream exists

Greetings, I just wanted to drop in a quick feature request to not show any status symbol for the current branch if an upstream for it does not exist. It's just a nice reminder of whether I pushed up the branch to the remote yet or not.

Thanks for the great script, I was going crazy without this after getting so used to posh-git on Windows!

Terminal issue: lines that wrap in (or near) colour changing statements do not wrap to the next line

I have a problem when the prompt string is a few characters longer than the window width and a branch name is displayed.

The screenshot below illustrates the issue.
schermafbeelding 2016-12-02 om 14 09 38
What you can see is the branch name is displayed, then the three stacked lines, but then the closing square bracket ] is shown in blue (instead of yellow) near the beginning of the first line. Also, the input cursor is shown close after the closing square bracket and dollar sign: ] $ |. The yellow pipe | is my cursor, yellow is the intended colour by the way. Also, the working directory is intended that way, it's there so the dir is quite long. Instead, I could have chosen a very long branch name for similar results.

In my ~/.bash_profile I have set the following.

export PROMPT_COMMAND='__posh_git_ps1 "$prefix" "$suffix";'$PROMPT_COMMAND

where $prefix is my username@hostname workingdir and $suffix is $, both with some colour specification, but nothing more.

When the Terminal window is a little smaller, the problem does not occur; see screenshot below for a terminal window of 77 characters wide. The one above is 80 characters wide. The problem occurs when the windows is 78, 79 or 80 characters wide. Narrower or wider windows behave correctly.
schermafbeelding 2016-12-02 om 14 21 23
For very narrow Terminal windows (or very long working directories) the problems become worse, especially when the prompt string should wrap around more than 2 lines. Try resizing the Terminal window in a similar situation as my current screenshots show, with quite a long working directory.

When will posh-git-sh retrieve git status automatically?

https://stackoverflow.com/questions/44815493/git-checkout-to-another-branch-cannot-show-its-correct-status

I met an issue related to git status, please see the thread in stackoverflow.com.

I want to double check with you, will posh-git-sh script update the local repository status such as git fetch when I ran git checkout master to swtich branches?

From the design of git, when running git checkout <branch_name> it will not fetch the information from remote repository. But one of my computer can get updated staus but another computer failed. I think it may be that I mis-config posh-git-sh in the computer.

But I don't know where I made mistake. What I did these days is to make my script install oh-my-zsh and posh-git-sh automaticaly. https://github.com/alexya/envconfig/blob/master/setup.sh

Any help will be much appreciated.

Can't get this to work properly in Xfce Terminal Emulator on Xubuntu 12.04.5 LTS

Hi there!

My predicament is the following: I'm a Windows user who's recently been forced to use Linux for work. One of the biggest things I was missing was the posh-git Powershell scripts included in the Github desktop application, so I was happy when I found this Linux port. However, I can't quite get it to work.

First, I tried following the instructions in the readme. However, setting PROMPT_COMMAND in .bashrc like instructed gave me the following error message:

bash: printf: missing unicode digit for \u

Which would then repeat for every command prompt line.

I then found the alternate instructions to replace PS1 in the git-prompt.sh script itself. I did so, adding the following line near the end of .bashrc:

PS1=$PS1'$(__git_ps1 " [(%s)]")\$ '

Which worked, sort of. It always just printed the current branch and nothing else. I eventually figured out I was dealing with the same problem as #9, so I worked around that by renaming the __git_ps1 function to __git_ps1_2, which finally gave me the actual output, except with broken color commands:

user@machine:~/path/to/repo [( [(\[\]\[\e[1;33m\] [\[\]\[\e[1;36m\]master\[\]\[\e[1;32m\] +1 ~0 -0\[\]\[\e[1;33m\] |\[\]\[\e[0;31m\] +0 ~4 -0\[\]\[\e[1;33m\]]\[\]\[\e[0;34m\]$\[\]\[\e[m\])])]$ 

Which is obviously not ideal. What am I doing wrong?

I'd appreciate any help very much.

Very slow compared to Powershell posh-git

Hey,

I just installed it and it seems that it does the trick, but it is very slow compared to powershell's posh-git. After each pressed 'enter' in the console I have to wait ca 3 sec or more to actually give me a new (re-counted) line. Is this normal behavior?

zsh instructions don't appear to work in macOS Catalina

Before we begin, I'm no expert with zsh (or any heavy shell customizations really), but since macOS Catalina made it the default shell on me, I figured I would just live with it. I'm also using plain-old Terminal.app, not iTerm2 or anything else.

I followed the instructions in the README, which at the time said to define precmd as follows:

precmd() {
  __posh_git_ps1 '\u@\h:\w ' '$ '
}

I pasted that into my .zshrc file and reloaded my terminal. However, this is what happened:
image
posh-git-sh worked, but prompt expansion wasn't. It took a bit of digging online before I found this comment on StackOverflow, showing that zsh prompt expansions are totally different from bash, which I'm guessing uses backslashes. Here's what worked for me:

precmd() {
  __posh_git_ps1 '%n@%m:%~ ' '$ '
}

image
I can submit a quick PR if it turns out the instructions need to be changed for zsh users. Thanks!

Documentation Request for Mac Bash Config

I am having a problem with understanding how to get this setup for a mac terminal bash environment. It was easy to setup the first part but I find this section to be entirely confusing.

a. If you are using bash, __git_ps1 can be used for PROMPT_COMMAND with two parameters,

 and , which are strings you would put in $PS1 before and after the status string generated by the git-prompt machinery. For example, the following

PROMPT_COMMAND='__git_ps1 "\u@\h:\w" "\$ "'$PROMPT_COMMAND
will show username, at-sign, host, colon, cwd, then various status strings, followed by dollar and space, as your prompt. Optionally, you can supply a third argument with a printf format string to fine-tune the output of the branch status.

break Python virtualenv display

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

toto@computer_name:~ $ mkdir -p ~/toto_test; cd ~/toto_test
toto@computer_name:~/toto_test $ git init
toto@computer_name:~/toto_test $ python -m venv .venv
toto@computer_name:~/toto_test $ source ./.venv/bin/activate

I should get something like that:

(.venv) toto@computer_name: ~/toto_test [main =]$

I got this instead

toto@computer_name: ~/toto_test [main =]$

Not working in OSX Mavericks

I get the following repo information output

( (\[\]\[\e[1;33m\] [\[\]\[\e[1;36m\]master\[\]\[\e[1;33m\]]\[\]\[\e[0;34m\]\[\]\[\e[m\] ))]$

Shell option `failglob` results in errors during prompt rendering

I usually enable the failglob shell option by default in bash via shopt -s failglob. This results in errors being displayed when combined with using __posh_git_ps1() in my PROMPT_COMMAND.

Here is an example:

~/p/dev [main ≡ +0 ~3 -0 !] $ shopt -s failglob
bash: no match: \[\e[m\]
bash: no match: \[\033[0;93m\]
bash: no match: \[\033[0;93m\]
bash: no match: \[\033[0;93m\]
bash: no match: \[\033[0;96m\]
bash: no match: \[\033[0;92m\]
bash: no match: \[\033[0;91m\]
bash: no match: \[\033[0;93m\]
bash: no match: \[\033[0;32m\]
bash: no match: \[\033[0;32m\]
bash: no match: \[\033[0;31m\]
bash: no match: \[\033[0;91m\]
bash: no match: \[\033[0;31m\]
bash: no match: \[\033[0;96m\]
bash: no match: \[\e[0m\]
~/p/dev [main ≡ +0 ~3 -0 !] $ shopt -u failglob
~/p/dev [main ≡ +0 ~3 -0 !] $

I was able to resolve the issue by changing these lines in the __posh_color() function:

From:

echo \\["$1"\\]

To:

(shopt -u failglob && echo \\["$1"\\])

However, I'm not sure if this might break other use cases. I could look into making sure it is robust.

Let me know if you're interested in a pull request with the fix + tests.

Consider Numeric Indicator of Commits Ahead/Behind

One feature I like about posh-git is the numeric indicator of how many commits I am behind or ahead after doing a fetch.

Have you considered adding such? Would you entertain a pull request?

Example:

Powershell

C:\source\DataMigrator [develop ↓4]>

Ubuntu

myuser@host:~/source/DataMigrator [develop ↓]$

GIT_PS1_ environment variables are no longer used for configuration

The comments/documentation in the CONFIG OPTIONS section of the script say that GIT_PS1_SHOWUPSTREAM and GIT_PS1_SHOWSTASHSTATE can be set to configure the script, but those were removed from code in e4141d4 and replaced with reading options from git config. GIT_PS1_SHOWCOLORHINTS is also not used anywhere.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.