Comments (13)
@chris-marsh Hey, just checking in to remind you about this, in case you actually have the time, but have accidentally forgotten.
from pureline.
With a clean clone of the repo, I solved the issue by globally replacing
wc -l
with
wc -l | tr -d ' '
from pureline.
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.
@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).
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.
@i-need-to-tell-you-something , thanks. Your screenshot explains it well, I'll have a look into this.
from pureline.
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.
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.
No problem. I will have a go this evening and push a branch for testing.
from pureline.
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.
@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.
@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.
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.
@andresrinivasan Seems to work for me as well:
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.
Improved with bash globbing.
PR #41
from pureline.
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)
- Multiline commands are visually broken HOT 2
- Needed different symbol for SSH with Hack font on MacOS HOT 1
- Challenged trying to create a module for iterm2 prompt HOT 1
- Unicode symbols HOT 5
- Background jobs count wrong HOT 4
- Git Segment - too many external calls to the git command HOT 3
- Show $SHLVL in prompt if greater than 1 HOT 2
- Right align segments HOT 1
- On some systems the prompt line wraps and overwrites the original line (without adding a new line) HOT 14
- Cursor jumps back three characters when wrapping the first line HOT 8
- Pretty broken in OSX HOT 3
- Using Control Characters resets the cursor HOT 9
- Phantom bg job HOT 1
- Kubernetes segment spams "error: current-context is not set" if kubectl available but not configured yet HOT 1
- duration_segment broken in macOS
- Running on a Pi (bash version 5.0.3) HOT 4
- Merging PR #66 reintroduced a bug in __pureline_pre HOT 1
- segments are not found HOT 1
- Adding a \n before the prompt IS A FUCKING NIGHTMARE HOT 2
- Add tmux, hg segments
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pureline.