Giter Club home page Giter Club logo

Comments (13)

ls-1N avatar ls-1N commented on July 22, 2024 1

@chris-marsh Hey, just checking in to remind you about this, in case you actually have the time, but have accidentally forgotten.

from pureline.

andresrinivasan avatar andresrinivasan commented on July 22, 2024 1

With a clean clone of the repo, I solved the issue by globally replacing

wc -l

with

wc -l | tr -d ' '

from pureline.

chris-marsh avatar chris-marsh commented on July 22, 2024

Can you give me some more information on this please?
The git module uses wc -l to count the lines returned. Leading spaces should not be an issue.

from pureline.

ls-1N avatar ls-1N commented on July 22, 2024

@MitchLillie Is there any hacky workaround for this so I can use pureline on macOS?

@chris-marsh EDIT: added screenshot of how it looks like for me (with two spots blurred out).
Screenshot 2019-06-17 at 16 22 01
I have:
updated bash via homebrew 5.0.7(1)
macOS Mojave 10.14.5

My profile is powerline_full_256col.conf with a few modules (background_jobs and newline) commented out.

from pureline.

chris-marsh avatar chris-marsh commented on July 22, 2024

@i-need-to-tell-you-something , thanks. Your screenshot explains it well, I'll have a look into this.

from pureline.

chris-marsh avatar chris-marsh commented on July 22, 2024

I'm thinking about replacing all use of 'wc -l' with this function ...

# fix for macos where 'wc -l' returns the number within a padded string
# arg: input is piped in same fashion as wc / wc -l would be used
# example usage:
#   job_count=$(jobs -p | stripped_lc)
function stripped_lc {
    read piped_input
    local line_count=$(echo "$piped_input" | wc -l)
    echo "${line_count// /}"
}

Feedback if this works and I can go ahead and make the changes.

from pureline.

ls-1N avatar ls-1N commented on July 22, 2024

I'm too beginner myself to know this. But if you tell me which files to edit or if I can pull your branch, then I'll gladly try it out. :)

from pureline.

chris-marsh avatar chris-marsh commented on July 22, 2024

No problem. I will have a go this evening and push a branch for testing.

from pureline.

MitchLillie avatar MitchLillie commented on July 22, 2024

Sorry for the delay in responding. Sounds like there is a good solution out there that @chris-marsh is working on.

@i-need-to-tell-you-something My extremely hacky solution is as follows, basically manually tapping into the various wc commands and piping to sed, as I initially suggested:

function custom_git_module {
        local git_branch=$(git rev-parse --abbrev-ref HEAD  2> /dev/null | sed -E 's/([a-zA-Z])?([a-zA-Z]+)?(\/?)(BPOR-[0-9]+)[a-zA-Z0-9-]+/\1\3\4/')
        if [ -n "$git_branch" ]; then
                local bg_color=$1
                local fg_color=$2
                local content="${symbols[git]} $git_branch$git"

                if [ -n "$3" -a -n "$(git status --porcelain)" ]; then
                        fg_color=$3
                fi

                local number_modified=$(git diff --name-only --diff-filter=M 2> /dev/null | wc -l | sed 's/^ *//' )
                if [ ! "$number_modified" -eq "0" ]; then
                        content+=" ${symbols[soft_separator]} ${symbols[plus]} $number_modified"
                fi

                local number_staged=$(git diff --staged --name-only --diff-filter=AM 2> /dev/null | wc -l | sed 's/^ *//')
                if [ ! "$number_staged" -eq "0" ]; then
                        content+=" ${symbols[soft_separator]} ${symbols[tick]} $number_staged"
                fi

                local number_conflicts=$(git diff --name-only --diff-filter=U 2> /dev/null | wc -l | sed 's/^ *//')
                if [ ! "$number_conflicts" -eq "0" ]; then
                        content+=" ${symbols[soft_separator]} ${symbols[cross]} $number_conflicts"
                fi

                local number_untracked=$(git ls-files --other --exclude-standard | wc -l | sed 's/^ *//')
                if [ ! "$number_untracked" -eq "0" ]; then
                        content+=" ${symbols[soft_separator]} ${symbols[untracked]} $number_untracked"
                fi

                PS1+=$(section_end $fg_color $bg_color)
                PS1+=$(section_content $fg_color $bg_color " $content ")
                __last_color=$bg_color
        fi
}

from pureline.

ls-1N avatar ls-1N commented on July 22, 2024

@MitchLillie I tried your hack and it was nice and clean, but it didn't display stashes or commits (ahead/behind) any more. None of the special symbols and only some of the numbers. It did display untracked and modified files. It did display branch name. An okay workaround, but of course I would like all of it to work.

I tested this by checking out an earlier commit. Also I verified that my git stash had 5 stashes/commits.

Screenshot 2019-08-27 at 11 28 21

@chris-marsh I applied the fix you last shared in this thread as well (having removed the custom_git_module from @MitchLillie ) and it didn't have the git module too long any more, but all of the git-related values for any repo and branch were displayed as "1". See attached image for better details. The git module background did change color when I modified files. The numbers didn't change when I had two rather than one modified file.

Screenshot 2019-08-27 at 11 13 30

The combination of the two fixes yielded a result that looked and behaved exactly like the custom_git_module results. To the untrained eye anyway. I didn't compare pixels.

My .pureline.conf is powerline_full_256col.conf with a few modules commented out and @MitchLillie's hack added.

EDIT: When I made this report my config file was out of date. Though after updating to newest config file I observed exactly the same results visually.

from pureline.

ls-1N avatar ls-1N commented on July 22, 2024

@andresrinivasan Seems to work for me as well:
Screenshot 2019-11-20 at 11 06 48
Now I just have to get used to all these "new" features. 😄

EDIT: I didn't observe any ill effect on my Linux from the same change.
Which one of us will make the pull request?

from pureline.

andresrinivasan avatar andresrinivasan commented on July 22, 2024

Improved with bash globbing.

PR #41

from pureline.

ls-1N avatar ls-1N commented on July 22, 2024

Review from end-user perspective:

TL;DR: Everything in the PR seems to be working as intended.

On Ubuntu 18.04:

Using GNU bash version 4.4.20(1)-release (x86_64-pc-linux-gnu).
Tested with my personal conf and with pureline/configs/powerline_full_256col.conf.

  • No visual difference between PR and master.

On macOS 10.15.2:

Using GNU bash version 5.0.7(1)-release (x86_64-apple-darwin18.5.0) (which I might have installed via homebrew).
Tested with my personal conf and with pureline/configs/powerline_full_256col.conf.

  • The master branch (obviously still) has those extended empty spaces.
  • The PR looks like master (and PR) look on Ubuntu.
  • The PR looks exactly like the previous workaround.

from pureline.

Related Issues (20)

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.